title: HostingEnvironment does not contain a definition for IsHosted
body: <p>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 <code>HostingEnvironment.IsHosted</code> method. Unfortunately if I write something like:</p>
  
  <pre><code>if (HostingEnvironment.IsHosted)
  {
      // on IIS
  }
  else
  {
     // not on IIS
  }
  </code></pre>
  
  <p>I get a compile error:</p>
  
  <blockquote>
    <p>HostingEnvironment does not contain a definition for IsHosted</p>
  </blockquote>
  
  <p>I'm using:
  <code>Microsoft.AspNetCore.Hosting;</code>
  <code>Microsoft.AspNetCore.Hosting.Internal;</code></p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Tried using <code>System.Web.Hosting.HostingEnvironment.IsHosted</code> as suggested but it didn't work</p>
  
  <p><a href="https://i.stack.imgur.com/3CMoe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3CMoe.png" alt="enter image description here"></a></p>