HttpRuntime HttpRuntime HttpRuntime HttpRuntime Class


Provides a set of ASP.NET run-time services for the current application.

public ref class HttpRuntime sealed
public sealed class HttpRuntime
type HttpRuntime = class
Public NotInheritable Class HttpRuntime


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="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<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();

<html xmlns="" >
    <title>HttpRuntime Example</title>
    <form id="form1" runat="server">
      <asp:label id="label1" runat="server"/>
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<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
<html xmlns="" >
    <title>HttpRuntime Example</title>
    <form id="Form1" runat="server">
      <asp:label id="label1" runat="server"/>


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.


HttpRuntime() HttpRuntime() HttpRuntime() HttpRuntime()

Initializes a new instance of the HttpRuntime class.


AppDomainAppId AppDomainAppId AppDomainAppId AppDomainAppId

Gets the application identification of the application domain where the HttpRuntime exists.

AppDomainAppPath AppDomainAppPath AppDomainAppPath AppDomainAppPath

Gets the physical drive path of the application directory for the application hosted in the current application domain.

AppDomainAppVirtualPath AppDomainAppVirtualPath AppDomainAppVirtualPath AppDomainAppVirtualPath

Gets the virtual path of the directory that contains the application hosted in the current application domain.

AppDomainId AppDomainId AppDomainId AppDomainId

Gets the domain identification of the application domain where the HttpRuntime instance exists.

AspClientScriptPhysicalPath AspClientScriptPhysicalPath AspClientScriptPhysicalPath AspClientScriptPhysicalPath

Gets the folder path for the ASP.NET client script files.

AspClientScriptVirtualPath AspClientScriptVirtualPath AspClientScriptVirtualPath AspClientScriptVirtualPath

Gets the virtual path for the ASP.NET client script files.

AspInstallDirectory AspInstallDirectory AspInstallDirectory AspInstallDirectory

Gets the physical path of the directory where the ASP.NET executable files are installed.

BinDirectory BinDirectory BinDirectory BinDirectory

Gets the physical path to the /bin directory for the current application.

Cache Cache Cache Cache

Gets the Cache for the current application.

ClrInstallDirectory ClrInstallDirectory ClrInstallDirectory ClrInstallDirectory

Gets the physical path to the directory where the common language runtime executable files are installed.

CodegenDir CodegenDir CodegenDir CodegenDir

Gets the physical path to the directory where ASP.NET stores temporary files (generated sources, compiled assemblies, and so on) for the current application.

IISVersion IISVersion IISVersion IISVersion

Gets the version of IIS that is hosting this application.

IsOnUNCShare IsOnUNCShare IsOnUNCShare IsOnUNCShare

Gets a value that indicates whether the application is mapped to a universal naming convention (UNC) share.

MachineConfigurationDirectory MachineConfigurationDirectory MachineConfigurationDirectory MachineConfigurationDirectory

Gets the physical path to the directory where the Machine.config file for the current application is located.

TargetFramework TargetFramework TargetFramework TargetFramework

Gets the version of the .NET Framework that the current web application targets.

UsingIntegratedPipeline UsingIntegratedPipeline UsingIntegratedPipeline UsingIntegratedPipeline

Gets a value that indicates whether the current application is running in the integrated-pipeline mode of IIS 7.0.

WebObjectActivator WebObjectActivator WebObjectActivator WebObjectActivator

Gets or sets the IServiceProvider instance for dependency injection support.


Close() Close() Close() Close()

Shuts down the HttpRuntime instance.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetNamedPermissionSet() GetNamedPermissionSet() GetNamedPermissionSet() GetNamedPermissionSet()

Returns the set of permissions associated with code groups.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ProcessRequest(HttpWorkerRequest) ProcessRequest(HttpWorkerRequest) ProcessRequest(HttpWorkerRequest) ProcessRequest(HttpWorkerRequest)

Drives all ASP.NET Web processing execution.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)
UnloadAppDomain() UnloadAppDomain() UnloadAppDomain() UnloadAppDomain()

Terminates the current application. The application restarts the next time a request is received for it.

Applies to

See also