Export (0) Print
Expand All

HttpRuntime Class

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

Namespace: System.Web
Assembly: System.Web (in system.web.dll)

'Declaration
Public NotInheritable Class HttpRuntime
'Usage
Dim instance As HttpRuntime

public final class HttpRuntime
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" %>
<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="VJ#"%>
<script runat="server">

  void Page_Load(Object sender, System.EventArgs e)
  {
    StringBuilder sb = new StringBuilder();
    String nl = "<br>";

    sb.Append("AppDomainAppId = " + 
      HttpRuntime.get_AppDomainAppId() + nl);
    sb.Append("AppDomainAppPath = " + 
      HttpRuntime.get_AppDomainAppPath() + nl);
    sb.Append("AppDomainAppVirtualPath = " + 
      HttpRuntime.get_AppDomainAppVirtualPath() + nl);
    sb.Append("AppDomainId = " + 
      HttpRuntime.get_AppDomainId() + nl);
    sb.Append("AspInstallDirectory = " + 
      HttpRuntime.get_AspInstallDirectory() + nl);
    sb.Append("BinDirectory = " + 
      HttpRuntime.get_BinDirectory() + nl);
    sb.Append("ClrInstallDirectory = " + 
      HttpRuntime.get_ClrInstallDirectory() + nl);
    sb.Append("CodegenDir = " + 
      HttpRuntime.get_CodegenDir() + nl);
    sb.Append("IsOnUNCShare = " + 
      Convert.ToString(HttpRuntime.get_IsOnUNCShare()) + nl);
    sb.Append("MachineConfigurationDirectory = " + 
      HttpRuntime.get_MachineConfigurationDirectory() + nl);

    label1.set_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>

System.Object
  System.Web.HttpRuntime

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft