简体   繁体   中英

System.Web.Hosting.HostingEnvironment in .NET Core?

We have a system that we're moving from .NET Framework to .NET Core.

One piece of this is a logging system that we configure at startup using SimpleInjector. So in App_Start\SimpleInjectorConfig we have:

private static void InitializeContainer(Container container)
{
    var application = System.Web.Hosting.HostingEnvironment.SiteName;
    var instance = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath;

    // .. use application and instance in configuring the logging system
}

And the problem, of course, is that in .NET Core there isn't any System.Web.Hosting.

I've been browsing around, and I haven't found a way of getting an equivalent to HostingEnvironment.SiteName in .NET Core - at startup, before any endpoints are active.

Any ideas?

Check the discussion around SiteName on these two .net Core Git tickets. and that will help you to take the decision weather it is really required.

github.com/dotnet/aspnetcore/issues/7400 and 
github.com/dotnet/aspnetcore/issues/17069

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM