HostingEnvironment クラス
アセンブリ: System.Web (system.web.dll 内)
構文
解説各マネージ アプリケーション ドメインには、アプリケーション管理機能およびアプリケーション サービスへのアクセスを提供する HostingEnvironment クラスの静的インスタンスがあります。
使用例HostingEnvironment オブジェクトから入手できるアプリケーション情報を表示する Web ページのコード例を次に示します。
<%@ 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 > <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>
<%@ 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 > <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>
.NET Framework のセキュリティ
継承階層System.MarshalByRefObject
System.Web.Hosting.HostingEnvironment
スレッド セーフ
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照HostingEnvironment コンストラクタ
アセンブリ: System.Web (system.web.dll 内)
構文
例外
解説HostingEnvironment コンストラクタは、HostingEnvironment オブジェクトを初期化します。HostingEnvironment コンストラクタは、アプリケーションの ApplicationManager オブジェクトによって 1 回だけ呼び出されます。HostingEnvironment コンストラクタを複数回呼び出すと、InvalidOperationException 例外がスローされます。
.NET Framework のセキュリティ
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照HostingEnvironment プロパティ
パブリック プロパティ| 名前 | 説明 | |
|---|---|---|
| ApplicationID | アプリケーションの一意の識別子を取得します。 |
| ApplicationPhysicalPath | アプリケーションのディレクトリへのディスク上の物理パスを取得します。 |
| ApplicationVirtualPath | アプリケーションのルートへの仮想パスを取得します。 |
| Cache | 現在のアプリケーションに対する Cache インスタンスを取得します。 |
| InitializationException | HostingEnvironment オブジェクトの初期化中にスローされた例外を取得します。 |
| IsHosted | 現在のアプリケーション ドメインが ApplicationManager オブジェクトによってホストされているかどうかを示す値を取得します。 |
| ShutdownReason | アプリケーションの終了理由を示す列挙値を返します。 |
| SiteName | サイトの名前を取得します。 |
| VirtualPathProvider | このアプリケーションの仮想パス プロバイダを取得します。 |
参照HostingEnvironment メソッド
パブリック メソッド
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
| MemberwiseClone | オーバーロードされます。 ( MarshalByRefObject から継承されます。) |
参照HostingEnvironment メンバ
アプリケーション ドメイン内でマネージ アプリケーションにアプリケーション管理機能およびアプリケーション サービスを提供します。このクラスは継承できません。
HostingEnvironment データ型で公開されるメンバを以下の表に示します。
パブリック コンストラクタ
パブリック プロパティ| 名前 | 説明 | |
|---|---|---|
| ApplicationID | アプリケーションの一意の識別子を取得します。 |
| ApplicationPhysicalPath | アプリケーションのディレクトリへのディスク上の物理パスを取得します。 |
| ApplicationVirtualPath | アプリケーションのルートへの仮想パスを取得します。 |
| Cache | 現在のアプリケーションに対する Cache インスタンスを取得します。 |
| InitializationException | HostingEnvironment オブジェクトの初期化中にスローされた例外を取得します。 |
| IsHosted | 現在のアプリケーション ドメインが ApplicationManager オブジェクトによってホストされているかどうかを示す値を取得します。 |
| ShutdownReason | アプリケーションの終了理由を示す列挙値を返します。 |
| SiteName | サイトの名前を取得します。 |
| VirtualPathProvider | このアプリケーションの仮想パス プロバイダを取得します。 |
パブリック メソッド
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
| MemberwiseClone | オーバーロードされます。 ( MarshalByRefObject から継承されます。) |
参照- HostingEnvironmentのページへのリンク