I'm developing a C# application and I need to find out if I'm under IIS or not. I've seen some question on SO about using the HostingEnvironment.IsHosted
method. Unfortunately if I write something like:
if (HostingEnvironment.IsHosted)
{
// on IIS
}
else
{
// not on IIS
}
I get a compile error:
HostingEnvironment does not contain a definition for IsHosted
I'm using:
Microsoft.AspNetCore.Hosting;
Microsoft.AspNetCore.Hosting.Internal;
EDIT
Tried using System.Web.Hosting.HostingEnvironment.IsHosted
as suggested but it didn't work