HttpRuntime クラス

定義

現在のアプリケーションの ASP.NET ランタイム サービスのセットを提供します。

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

次の例では、現在のアプリケーション ドメインを表す HttpRuntime クラスのプロパティを取得し、ブラウザーに表示する方法を示します。

<%@ 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 xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>HttpRuntime Example</title>
  </head>
  <body>    
    <form id="form1" runat="server">
      <asp:label id="label1" runat="server"/>
    </form>
  </body>
</html>
<%@ 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 xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>HttpRuntime Example</title>
  </head>
  <body>    
    <form id="Form1" runat="server">
      <asp:label id="label1" runat="server"/>
    </form>
  </body>
</html>

注釈

HttpRuntime オブジェクトは、HTTP 要求を処理する ASP.NET パイプライン モデルの先頭で使用されます。 ProcessRequest メソッドは、後続のすべての ASP.NET Web 処理を実行します。

ページ開発者は、 HttpRuntime クラスのプロパティを使用して、診断目的で現在のアプリケーション ドメインに関する情報を確認できます。 カスタム プロセス パイプラインまたはカスタム ホスティング環境を作成する開発者は、HttpWorkerRequest または SimpleWorkerRequest クラスから派生したクラスからProcessRequest メソッドを呼び出す必要があります。

コンストラクター

名前 説明
HttpRuntime()

HttpRuntime クラスの新しいインスタンスを初期化します。

プロパティ

名前 説明
AppDomainAppId

HttpRuntimeが存在するアプリケーション ドメインのアプリケーション ID を取得します。

AppDomainAppPath

現在のアプリケーション ドメインでホストされているアプリケーションのアプリケーション ディレクトリの物理ドライブ パスを取得します。

AppDomainAppVirtualPath

現在のアプリケーション ドメインでホストされているアプリケーションを含むディレクトリの仮想パスを取得します。

AppDomainId

HttpRuntime インスタンスが存在するアプリケーション ドメインのドメイン ID を取得します。

AspClientScriptPhysicalPath

ASP.NET クライアント スクリプト ファイルのフォルダー パスを取得します。

AspClientScriptVirtualPath

ASP.NET クライアント スクリプト ファイルの仮想パスを取得します。

AspInstallDirectory

ASP.NET 実行可能ファイルがインストールされているディレクトリの物理パスを取得します。

BinDirectory

現在のアプリケーションの /bin ディレクトリへの物理パスを取得します。

Cache

現在のアプリケーションの Cache を取得します。

ClrInstallDirectory

共通言語ランタイム実行可能ファイルがインストールされているディレクトリへの物理パスを取得します。

CodegenDir

ASP.NET が現在のアプリケーションの一時ファイル (生成されたソース、コンパイル済みアセンブリなど) を格納するディレクトリへの物理パスを取得します。

IISVersion

このアプリケーションをホストしている IIS のバージョンを取得します。

IsOnUNCShare

アプリケーションが汎用名前付け規則 (UNC) 共有にマップされているかどうかを示す値を取得します。

MachineConfigurationDirectory

現在のアプリケーションの Machine.config ファイルが配置されているディレクトリへの物理パスを取得します。

TargetFramework

現在の Web アプリケーションが対象とする .NET Framework のバージョンを取得します。

UsingIntegratedPipeline

現在のアプリケーションが IIS 7.0 の統合パイプライン モードで実行されているかどうかを示す値を取得します。

WebObjectActivator

依存関係の挿入をサポートする IServiceProvider インスタンスを取得または設定します。

メソッド

名前 説明
Close()

HttpRuntime インスタンスをシャットダウンします。

Equals(Object)

指定したオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetNamedPermissionSet()

コード グループに関連付けられているアクセス許可のセットを返します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Objectの簡易コピーを作成します。

(継承元 Object)
ProcessRequest(HttpWorkerRequest)

すべての ASP.NET Web 処理の実行を駆動します。

ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)
UnloadAppDomain()

現在のアプリケーションを終了します。 アプリケーションは、次に要求を受信すると再起動します。

適用対象

こちらもご覧ください