HostingEnvironment クラス

定義

アプリケーション ドメイン内でマネージド アプリケーションにアプリケーション管理機能およびアプリケーション サービスを提供します。 このクラスは継承できません。

public ref class HostingEnvironment sealed : MarshalByRefObject
public sealed class HostingEnvironment : MarshalByRefObject
type HostingEnvironment = class
    inherit MarshalByRefObject
Public NotInheritable Class HostingEnvironment
Inherits MarshalByRefObject
継承
HostingEnvironment

次のコード例は、オブジェクトから HostingEnvironment 使用できるアプリケーション情報を表示する Web ページです。

<%@ Page Language="C#" %>

<%@ Import Namespace="System.Web.Hosting" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
  protected void Page_Load(object sender, EventArgs e)
  {
    appID.Text = HostingEnvironment.ApplicationID;
    appPPath.Text = HostingEnvironment.ApplicationPhysicalPath;
    appVPath.Text = HostingEnvironment.ApplicationVirtualPath;
    siteName.Text = HostingEnvironment.SiteName;
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>Hosting Environment Sample</title>
</head>
<body>
  <form id="form1" runat="server">
    <div>
      <table>
        <tr>
          <td colspan="2">
            <b>HostingEnvironment Properties</b></td>
        </tr>
        <tr>
          <td>
            Application ID:
          </td>
          <td>
            <asp:Label ID="appID" runat="server" />
          </td>
        </tr>
        <tr>
          <td>
            Application Physical Path:
          </td>
          <td>
            <asp:Label ID="appPPath" runat="server" />
          </td>
        </tr>
        <tr>
          <td>
            Application Virtual Path:
          </td>
          <td>
            <asp:Label ID="appVPath" runat="server" />
          </td>
        </tr>
        <tr>
          <td>
            Site Name:
          </td>
          <td>
            <asp:Label ID="siteName" runat="server" />
          </td>
        </tr>
      </table>
    </div>
  </form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Hosting" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    appID.Text = HostingEnvironment.ApplicationID
    appPPath.Text = HostingEnvironment.ApplicationPhysicalPath
    appVPath.Text = HostingEnvironment.ApplicationVirtualPath
    siteName.Text = HostingEnvironment.SiteName
  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
  <title>Hosting Environment Sample</title>
</head>
<body>
  <form id="form1" runat="server">
    <div>
      <table>
        <tr>
          <td colspan="2">
            <b>HostingEnvironment Properties</b></td>
        </tr>
        <tr>
          <td>
            Application ID:
          </td>
          <td>
            <asp:Label ID="appID" runat="server" />
          </td>
        </tr>
        <tr>
          <td>
            Application Physical Path:
          </td>
          <td>
            <asp:Label ID="appPPath" runat="server" />
          </td>
        </tr>
        <tr>
          <td>
            Application Virtual Path:
          </td>
          <td>
            <asp:Label ID="appVPath" runat="server" />
          </td>
        </tr>
        <tr>
          <td>
            Site Name:
          </td>
          <td>
            <asp:Label ID="siteName" runat="server" />
          </td>
        </tr>
      </table>
    </div>
  </form>
</body>
</html>

注釈

各マネージド アプリケーション ドメインには、アプリケーション管理機能とアプリケーション サービスへのアクセスを HostingEnvironment 提供するクラスの静的インスタンスが含まれています。

コンストラクター

HostingEnvironment()

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

プロパティ

ApplicationHost

このプロパティは、ASP.NET インフラストラクチャをサポートしており、コードから直接使用するためのものではありません。

ApplicationID

アプリケーションの一意の識別子を取得します。

ApplicationMonitors

アプリケーションを正常な状態に保つために ASP.NET サブシステムによって使用されている置き換え可能なモニター オブジェクトのグループを取得します。

ApplicationPhysicalPath

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

ApplicationVirtualPath

アプリケーションのルートへの仮想パスを取得します。

Cache

現在のアプリケーションに対する Cache インスタンスを取得します。

InClientBuildManager

ホスティング環境が ASP.NET ビルド システムにアクセスできるかどうかを示す値を取得します。

InitializationException

HostingEnvironment オブジェクトの初期化中にスローされた例外を取得します。

IsDevelopmentEnvironment

現在のアプリケーションが開発環境で実行されているかどうかを示す値を取得します。

IsHosted

現在のアプリケーション ドメインが ApplicationManager オブジェクトによってホストされているかどうかを示す値を取得します。

MaxConcurrentRequestsPerCPU

CPU あたりの同時実行される要求の最大数を取得または設定します。

MaxConcurrentThreadsPerCPU

CPU あたりの同時実行されるスレッドの最大数を取得または設定します。

ShutdownReason

アプリケーションの終了理由を示す列挙値を返します。

SiteName

サイトの名前を取得します。

VirtualPathProvider

このアプリケーションの仮想パス プロバイダーを取得します。

メソッド

CreateObjRef(Type)

リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。

(継承元 MarshalByRefObject)
DecrementBusyCount()

ホスト環境のビジー オブジェクトの数を 1 つ減らします。

Equals(Object)

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

(継承元 Object)
GetHashCode()

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

(継承元 Object)
GetLifetimeService()
互換性のために残されています。

対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。

(継承元 MarshalByRefObject)
GetType()

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

(継承元 Object)
Impersonate()

アプリケーション ID によって表されるユーザーを偽装します。

Impersonate(IntPtr)

指定したユーザー トークンによって表されるユーザーを偽装します。

Impersonate(IntPtr, String)

指定した仮想パスまたは指定したユーザー トークンについて構成設定で指定されたユーザーを偽装します。

IncrementBusyCount()

ホスト環境のビジー オブジェクトの数を 1 つ増やします。

InitializeLifetimeService()

リースが作成されないようにすることで、HostingEnvironment オブジェクトに無期限の有効期間を指定します。

InitiateShutdown()

このホストに関連付けられている web アプリケーションのシャットダウンを開始し、登録済みのオブジェクトをシステムから削除します。

MapPath(String)

サーバー上の物理パスに仮想パスを割り当てます。

MemberwiseClone()

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

(継承元 Object)
MemberwiseClone(Boolean)

現在の MarshalByRefObject オブジェクトの簡易コピーを作成します。

(継承元 MarshalByRefObject)
MessageReceived()

このメソッドは、ASP.NET インフラストラクチャをサポートしており、コードから直接使用することを意図したものではありません。

QueueBackgroundWorkItem(Action<CancellationToken>)

どの要求とも独立した形で、バック グラウンドで実行するタスクをスケジュールします。

QueueBackgroundWorkItem(Func<CancellationToken,Task>)

どの要求とも独立した形で、バック グラウンドで実行するタスクをスケジュールします。

RegisterObject(IRegisteredObject)

アプリケーションの登録済みオブジェクトのリストにオブジェクトを追加します。

RegisterVirtualPathProvider(VirtualPathProvider)

ASP.NET コンパイル システムに新しい VirtualPathProvider インスタンスを登録します。

SetCultures()

現在のスレッドを、アプリケーションの構成ファイルで指定されたカルチャに設定します。

SetCultures(String)

現在のカルチャを、指定した仮想パスのカルチャに設定します。

ToString()

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

(継承元 Object)
UnregisterObject(IRegisteredObject)

アプリケーションの登録済みのオブジェクトのリストからオブジェクトを削除します。

events

StopListening

[.NET Framework 4.5.1 のみでサポート]

発生した時、ワーカーの処理か、このホストに関連付けられているアプリケーション プールが新しい要求のリッスンを停止して、最終的にシャット ダウンされるときに発生します。

適用対象