Provides a set of ASP.NET run-time services for the current application.
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _ Public NotInheritable Class HttpRuntime
Dim instance As HttpRuntime
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] public sealed class HttpRuntime
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)] public ref class HttpRuntime sealed
public final class HttpRuntime
The HttpRuntime object is used at the beginning of the ASP.NET pipeline model that processes HTTP requests. The ProcessRequest method drives all subsequent ASP.NET Web processing.
Page developers can use the HttpRuntime class properties to find out information about the current application domain for diagnostic purposes, for example. Developers creating custom process pipeline or a custom hosting environment should call the ProcessRequest method from a class derived from the HttpWorkerRequest or SimpleWorkerRequest class.
The following example demonstrates how to get properties of the HttpRuntime class representing the current application domain and display them to the browser.
<%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Dim sb As New StringBuilder() Dim nl As String = "<br />" sb.Append("AppDomainAppId = " & _ HttpRuntime.AppDomainAppId & nl) sb.Append("AppDomainAppPath = " & _ HttpRuntime.AppDomainAppPath & nl) sb.Append("AppDomainAppVirtualPath = " & _ HttpRuntime.AppDomainAppVirtualPath & nl) sb.Append("AppDomainId = " & _ HttpRuntime.AppDomainId & nl) sb.Append("AspInstallDirectory = " & _ HttpRuntime.AspInstallDirectory & nl) sb.Append("BinDirectory = " & _ HttpRuntime.BinDirectory & nl) sb.Append("ClrInstallDirectory = " & _ HttpRuntime.ClrInstallDirectory & nl) sb.Append("CodegenDir = " & _ HttpRuntime.CodegenDir & nl) sb.Append("IsOnUNCShare = " & _ HttpRuntime.IsOnUNCShare.ToString() & nl) sb.Append("MachineConfigurationDirectory = " & _ HttpRuntime.MachineConfigurationDirectory & nl) label1.Text = sb.ToString() End Sub </script> <html > <head> <title>HttpRuntime Example</title> </head> <body> <form id="Form1" runat="server"> <asp:label id="label1" runat="server"/> </form> </body> </html>
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> void Page_Load(Object sender, System.EventArgs e) { StringBuilder sb = new StringBuilder(); String nl = "<br />"; sb.Append("AppDomainAppId = " + HttpRuntime.AppDomainAppId + nl); sb.Append("AppDomainAppPath = " + HttpRuntime.AppDomainAppPath + nl); sb.Append("AppDomainAppVirtualPath = " + HttpRuntime.AppDomainAppVirtualPath + nl); sb.Append("AppDomainId = " + HttpRuntime.AppDomainId + nl); sb.Append("AspInstallDirectory = " + HttpRuntime.AspInstallDirectory + nl); sb.Append("BinDirectory = " + HttpRuntime.BinDirectory + nl); sb.Append("ClrInstallDirectory = " + HttpRuntime.ClrInstallDirectory + nl); sb.Append("CodegenDir = " + HttpRuntime.CodegenDir + nl); sb.Append("IsOnUNCShare = " + HttpRuntime.IsOnUNCShare.ToString() + nl); sb.Append("MachineConfigurationDirectory = " + HttpRuntime.MachineConfigurationDirectory + nl); label1.Text = sb.ToString(); } </script> <html > <head> <title>HttpRuntime Example</title> </head> <body> <form id="form1" runat="server"> <asp:label id="label1" runat="server"/> </form> </body> </html>
for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98