How to get current iis website name in ConfigureService() method in startup class in AspCore 2?

930 Views Asked by At

I need to get current iis website (started website) name in configureservice method in statup class in aspcore2. I need it in sub class of configureservice I try HttpContextAccessor but it always is null

1

There are 1 best solutions below

2
Paul Hieltjes On

You could use the following code in the startup class:

 public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
        var name = Configuration["ASPNETCORE_APPL_PATH"];
    }

IIS

Code