title: MVC Web Api won't allow Windows Authentication
body: <p>I have a simple MVC web api 2 IIS hosted application which I want to enable windows authentication (initially not using Owin). I am running this on my development machine and running as local IIS.</p>
  
  <p>So, from what I could find, I need to add the following to the web.config</p>
  
  <p>1: to the following section the authentication mode="Windows" </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;system.web&gt;
    &lt;compilation debug="true" targetFramework="4.5.1"/&gt;
    &lt;httpRuntime targetFramework="4.5.1"/&gt;
    &lt;authentication mode="Windows" /&gt;
  &lt;/system.web&gt;
  </code></pre>
  
  <p>2: Then add the following</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;system.webServer&gt;
    &lt;security&gt;
      &lt;authentication&gt;
        &lt;windowsAuthentication enabled="true"/&gt;
      &lt;/authentication&gt;
    &lt;/security&gt;
  </code></pre>
  
  <p>When I add the above and run the application (in debug from Dev studio), I get the following error</p>
  
  <p><b>HTTP Error 500.19 - Internal Server Error</b></p>
  
  <p><b>Config Error</b>    This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false". </p>
  
  <p>and then it specifically points to this web config entry</p>
  
  <p><b>Config Source:</b>
  </p>
  
  <pre><code>37:     &lt;authentication&gt;
  38:       &lt;windowsAuthentication enabled="true"/&gt;
  39:     &lt;/authentication&gt;
  </code></pre>
  
  <p>Anyone have any ideas why I would be getting this?</p>
  
  <p>Also, I noticed when I switch to IIS express, that in the project properties, the Windows Authentication is set to disabled, and grayed out so I cannot set it here either.</p>
  
  <p>Thanks in advance for any help!</p>