IHostingEnvironment 接口

定义

注意

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

提供有关其中正在运行应用程序的宿主环境的信息。Provides information about the hosting environment an application is running in.

此类型已过时,并将从未来版本中删除。This type is obsolete and will be removed in a future version. 建议的替代项为 Microsoft.Extensions.Hosting.IHostEnvironment。The recommended alternative is Microsoft.Extensions.Hosting.IHostEnvironment.

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.Extensions.Hosting.IHostEnvironment.", 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.Extensions.Hosting.IHostEnvironment.", false)>]
type IHostingEnvironment = interface
Public Interface IHostingEnvironment
属性

属性

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

获取或设置指向 ContentRootPathIFileProviderGets 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 of the "environment" key as specified in configuration.

扩展方法

IsDevelopment(IHostingEnvironment)

检查当前主机环境名称是否为 DevelopmentChecks if the current hosting environment name is Development. 此 API 不应在库中使用。有关详细信息,请参阅注解。This API should not be used in libraries, see remarks for details.

IsEnvironment(IHostingEnvironment, String)

将当前主机环境名称与指定的值进行比较。Compares the current hosting environment name against the specified value. 库作者应避免使用此 API。有关详细信息,请参阅注解。Library authors should avoid using this API, see remarks for details.

IsProduction(IHostingEnvironment)

检查当前主机环境名称是否为 ProductionChecks if the current hosting environment name is Production. 此 API 不应在库中使用。有关详细信息,请参阅注解。This API should not be used in libraries, see remarks for details.

IsStaging(IHostingEnvironment)

检查当前主机环境名称是否为 StagingChecks if the current hosting environment name is Staging. 此 API 不应在库中使用。有关详细信息,请参阅注解。This API should not be used in libraries, see remarks for details.

适用于