HostingEnvironment Class
.NET Framework 4.5
Provides application-management functions and application services to a managed application within its application domain. This class cannot be inherited.
Namespace: System.Web.Hosting
Assembly: System.Web (in System.Web.dll)
The HostingEnvironment type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | HostingEnvironment | Infrastructure. Initializes a new instance of the HostingEnvironment class. |
| Name | Description | |
|---|---|---|
![]() ![]() | ApplicationHost | This property supports the ASP.NET infrastructure and is not intended to be used directly from your code. |
![]() ![]() | ApplicationID | Gets the unique identifier of the application. |
![]() ![]() | ApplicationPhysicalPath | Gets the physical path on disk to the application's directory. |
![]() ![]() | ApplicationVirtualPath | Gets the root virtual path of the application. |
![]() ![]() | Cache | Gets the Cache instance for the current application. |
![]() ![]() | InClientBuildManager | Gets a value that indicates whether the hosting environment has access to the ASP.NET build system. |
![]() ![]() | InitializationException | Gets any exception thrown during initialization of the HostingEnvironment object. |
![]() ![]() | IsDevelopmentEnvironment | Gets a value indicating whether the current application is in a development environment. |
![]() ![]() | IsHosted | Gets a value indicating whether the current application domain is being hosted by an ApplicationManager object. |
![]() ![]() | MaxConcurrentRequestsPerCPU | Gets or sets the maximum concurrent requests per CPU. |
![]() ![]() | MaxConcurrentThreadsPerCPU | Gets or sets the maximum concurrent threads per CPU. |
![]() ![]() | ShutdownReason | Returns an enumerated value that indicates why the application terminated. |
![]() ![]() | SiteName | Gets the name of the site. |
![]() ![]() | VirtualPathProvider | Gets the virtual path provider for this application. |
| Name | Description | |
|---|---|---|
![]() | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.) |
![]() ![]() | DecrementBusyCount | Reduces the count of busy objects in the hosted environment by one. |
![]() | Equals(Object) | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() ![]() | Impersonate() | Impersonates the user represented by the application identity. |
![]() ![]() | Impersonate(IntPtr) | Impersonates the user represented by the specified user token. |
![]() ![]() | Impersonate(IntPtr, String) | Impersonates the user specified by the configuration settings for the specified virtual path, or the specified user token. |
![]() ![]() | IncrementBusyCount | Increases the count of busy objects in the hosted environment by one. |
![]() | InitializeLifetimeService | Infrastructure. Gives the HostingEnvironment object an infinite lifetime by preventing a lease from being created. (Overrides MarshalByRefObject.InitializeLifetimeService().) |
![]() ![]() | InitiateShutdown | Starts shutting down the Web application associated with this host and removes registered objects from the system. |
![]() ![]() | MapPath | Maps a virtual path to a physical path on the server. |
![]() ![]() | MessageReceived | This method supports the ASP.NET infrastructure and is not intended to be used directly from your code. |
![]() ![]() | RegisterObject | Places an object in the list of registered objects for the application. |
![]() ![]() | RegisterVirtualPathProvider | Registers a new VirtualPathProvider instance with the ASP.NET compilation system. |
![]() ![]() | SetCultures() | Sets the current thread to the culture specified in the application configuration file. |
![]() ![]() | SetCultures(String) | Sets the current thread to the culture of the specified virtual path. |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() ![]() | UnregisterObject | Removes an object from the list of registered objects for the application. |
The following code example is a Web page that displays the application information available from the HostingEnvironment object.
<%@ 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>
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
