Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

IHostingEnvironment Interface

Definition

Namespace:
Microsoft.AspNetCore.Hosting
Assembly:
Microsoft.AspNetCore.Hosting.Abstractions.dll
Package:
Microsoft.AspNetCore.Hosting.Abstractions v1.0.0
Package:
Microsoft.AspNetCore.Hosting.Abstractions v1.1.0
Package:
Microsoft.AspNetCore.App.Ref v10.0.0
Package:
Microsoft.AspNetCore.App.Ref v11.0.0-preview.4.26230.115
Package:
Microsoft.AspNetCore.Hosting.Abstractions v2.0.0
Package:
Microsoft.AspNetCore.Hosting.Abstractions v2.1.0
Package:
Microsoft.AspNetCore.Hosting.Abstractions v2.2.0
Package:
Microsoft.AspNetCore.App.Ref v3.0.1
Package:
Microsoft.AspNetCore.App.Ref v3.1.10
Package:
Microsoft.AspNetCore.App.Ref v5.0.0
Package:
Microsoft.AspNetCore.App.Ref v6.0.36
Package:
Microsoft.AspNetCore.App.Ref v7.0.5
Package:
Microsoft.AspNetCore.App.Ref v8.0.19
Package:
Microsoft.AspNetCore.App.Ref v9.0.8
Source:
IHostingEnvironment.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Caution

This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.AspNetCore.Hosting.IWebHostEnvironment.

Provides information about the web hosting environment an application is running in.

This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.AspNetCore.Hosting.IWebHostEnvironment.

public interface class IHostingEnvironment
public interface IHostingEnvironment
[System.Obsolete("This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.AspNetCore.Hosting.IWebHostEnvironment.", false)]
public interface IHostingEnvironment
type IHostingEnvironment = interface
[<System.Obsolete("This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.AspNetCore.Hosting.IWebHostEnvironment.", false)>]
type IHostingEnvironment = interface
Public Interface IHostingEnvironment
Attributes

Properties

Name Description
ApplicationName

Gets or sets the name of the application. This property is automatically set by the host to the assembly containing the application entry point.

ContentRootFileProvider

Gets or sets an IFileProvider pointing at ContentRootPath.

ContentRootPath

Gets or sets the absolute path to the directory that contains the application content files.

EnvironmentName

Gets or sets the name of the environment. The host automatically sets this property to the value of the "ASPNETCORE_ENVIRONMENT" environment variable, or "environment" as specified in any other configuration source.

WebRootFileProvider

Gets or sets an IFileProvider pointing at WebRootPath.

WebRootPath

Gets or sets the absolute path to the directory that contains the web-servable application content files.

Extension Methods

Name Description
IsDevelopment(IHostingEnvironment)

Checks if the current hosting environment name is Development.

IsEnvironment(IHostingEnvironment, String)

Compares the current hosting environment name against the specified value.

IsProduction(IHostingEnvironment)

Checks if the current hosting environment name is Production.

IsStaging(IHostingEnvironment)

Checks if the current hosting environment name is Staging.

Applies to


Feedback

Was this page helpful?