Freigeben über


HttpRuntime-Klasse

Stellt einen Satz von ASP.NET-Laufzeitdiensten für die aktuelle Anwendung bereit.

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

Syntax

'Declaration
Public NotInheritable Class HttpRuntime
'Usage
Dim instance As HttpRuntime
public sealed class HttpRuntime
public ref class HttpRuntime sealed
public final class HttpRuntime
public final class HttpRuntime

Hinweise

Das HttpRuntime-Objekt wird am Anfang des ASP.NET-Pipelinemodells verwendet, das HTTP-Anforderungen verarbeitet. Die ProcessRequest-Methode steuert die gesamte nachfolgende ASP.NET-Webverarbeitung.

Entwickler von Seiten können mithilfe der HttpRuntime-Klasseneigenschaften beispielsweise Informationen zur aktuellen Anwendungsdomäne für Diagnosezwecke ermitteln. Entwickler sollten beim Erstellen einer benutzerdefinierten Prozesspipeline oder einer benutzerdefinierten Hostumgebung die ProcessRequest-Methode einer Klasse aufrufen, die von der HttpWorkerRequest-Klasse oder der SimpleWorkerRequest-Klasse abgeleitet ist.

Beispiel

Im folgenden Beispiel wird veranschaulicht, wie die Eigenschaften der HttpRuntime-Klasse abgerufen werden, die die aktuelle Anwendungsdomäne darstellen, und wie diese im Browser angezeigt werden.

<%@ 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="C#" %>
<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 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>

.NET Framework-Sicherheit

Vererbungshierarchie

System.Object
  System.Web.HttpRuntime

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

HttpRuntime-Member
System.Web-Namespace
ProcessRequest
HttpWorkerRequest
SimpleWorkerRequest

Weitere Ressourcen

Seiten- und Anwendungskontext in ASP.NET-Webanwendungen