title: Why isn't IIS 7 returning JSON faults? Works on *my* machine
body: <p>I am following the principles from the following blog post and I am getting the behavior that I expect when I debug my WCF Service using the Visual Studio 2010's built in web server.</p>
  
  <p><a href="http://zamd.net/2008/07/08/error-handling-with-webhttpbinding-for-ajaxjson/">http://zamd.net/2008/07/08/error-handling-with-webhttpbinding-for-ajaxjson/</a></p>
  
  <p>When my application throws a FaultException(), I can see the JSON representation of that fault on my local machine.  The application also returns the appropriate HttpStatusCode (in this case, 401 Unauthorized), which is the desired behavior.</p>
  
  <pre><code>{"Code":"UserNotLoggedInFault","DisplayText":"You must be logged in to access this resource.","InternalText":"User is not logged in"}
  </code></pre>
  
  <p>When I deploy my application to IIS 7.0 though, I get the correct HttpStatusCode, but the html returned is the generic text that is associated with the status code:</p>
  
  <blockquote>
    <p>You do not have permission to view this directory or page.</p>
  </blockquote>
  
  <p>Because this is working locally, I assume that the issue is an IIS configuration setting.  I have already removed the IIS: Error Pages values that were intercepting error statuses (it used to return formatted HTML from %SystemDrive%\inetpub\custerr\\401.htm)</p>
  
  <p>Does anyone know what IIS settings I need to change to allow the JSON response to pass through when an HTTP Status outside of the 200 range is returned?  ...or perhaps there is something else I need to do?</p>
  
  <hr>
  
  <p><strong>UPDATE #1</strong></p>
  
  <p>This only appears to be happening when my application throws a FaultException that also sets the HttpStatusCode to Unauthorized (401).  If my application returns a status code of 404 Not Found, then the JSON is returned properly.</p>
  
  <p>The question still stands, but I suppose it only applies to returning a 401 Unauthorized status code.</p>
  
  <p>Here are some screenshots of the response as captured by Charles Web Proxy</p>
  
  <p><a href="http://imgur.com/a/MkRRI">http://imgur.com/a/MkRRI</a></p>
  
  <p>Here is what it looks like when I hit my local machine</p>
  
  <p><a href="http://imgur.com/a/RMmsa">http://imgur.com/a/RMmsa</a></p>
  
  <hr>
  
  <p><strong>UPDATE #2</strong></p>
  
  <p>So this does <em>not</em> happen if I remote desktop into the server and hit the site via localhost.  When I hit my URL that requires authentication, I get the proper JSON object returned.</p>
  
  <p><a href="http://i.imgur.com/J5oNn.png">http://i.imgur.com/J5oNn.png</a></p>
  
  <p>So does that mean that IIS treats 401 status code differently and that non-authenticated users are shielded from the proper response?</p>