HttpRuntime クラス
アセンブリ: System.Web (system.web.dll 内)


HttpRuntime オブジェクトは、HTTP 要求を処理する ASP.NET パイプライン モデルで最初に使用されます。ProcessRequest メソッドは、後続のすべての ASP.NET Web 処理を制御します。
ページを開発する場合、HttpRuntime クラス プロパティを使用して、診断などの目的で、現在のアプリケーション ドメインに関する情報を確認できます。カスタム プロセス パイプラインまたはカスタム ホスト環境を作成する場合は、ProcessRequest メソッドを HttpWorkerRequest クラスまたは SimpleWorkerRequest クラスの派生クラスから呼び出す必要があります。

現在のアプリケーション ドメインを表す、HttpRuntime クラスのプロパティを取得して、それをブラウザに表示する方法を次のコード例に示します。
<%@ 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>


System.Web.HttpRuntime


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


HttpRuntime メンバ
System.Web 名前空間
ProcessRequest
HttpWorkerRequest
SimpleWorkerRequest
その他の技術情報
ASP.NET Web アプリケーションのページとアプリケーション コンテキスト
- HttpRuntime クラスのページへのリンク