title: IIS7 returning 500 for status code 401 when asp.net mvc app writes it to the response
body: <p>Our mvc application sets the response status code to 401 and sets TrySkipIisCustomErrors to true under some circumstances. </p>
  
  <p>I can see from the IIS log that it is getting this status code:</p>
  
  <pre><code>2012-05-04 01:32:42 10.212.98.183 POST /v1.07/session - 80 - 10.24.22.26 curl/7.20.1+(i686-pc-cygwin)+libcurl/7.20.1+OpenSSL/0.9.8r+zlib/1.2.5+libidn/1.18+libssh2/1.2.5 401 0 0 48325
  </code></pre>
  
  <p>However the response I receive in the client is 500:</p>
  
  <pre><code>&lt; HTTP/1.1 500 Internal Server Error
  &lt; Content-Type: text/html
  &lt; Server: Microsoft-IIS/7.0
  &lt; Date: Fri, 04 May 2012 02:31:18 GMT
  &lt; Content-Length: 75
  &lt;
  * Connection #0 to host webserver left intact
  * Closing connection #0
  The page cannot be displayed because an internal server error has occurred.
  </code></pre>
  
  <p>I have tried various other settings in the web.config for the mvc application around httpErrors and customErrors, none of which seem to make a difference.</p>
  
  <p>How can I configure IIS to return the actual response and not 500?</p>