I'm trying to get the name of my ASP.NET 6 app hosted in IIS. What I need is exactly this name with proper casing:
In .NET Framework 4.8, this name was provided by HttpRequest.ApplicationPath and it was returned with proper casing (as configured in IIS, not as in the coming request's URL). However, it doesn't exist in .NET 6.
I tried:
HttpContext.Request.PathBase, but it returns the path exactly as in the requesting URL, not as in the IIS- injecting
IServerAddressesFeatureandIWebHostEnvironment, but none of them contains the name from IIS with correct casing IServerAddressesFeature, but also didn't find anything relevant here- getting server variables:
IServerVariablesFeature serverVars = HttpContext.Features.Get<IServerVariablesFeature>()and then the IIS Site name:string iis_version = serverVars["INSTANCE_NAME"](see documentation here), but it returns the app name in capital letters (MYSITE.WEB)
Does anyone know how to get this site's name as configured in IIS (with proper casing)?
