title: How to get exception information when calling JSON web service
body: <p>In .NET 3.5, I had the following code:</p>
  
  <pre><code>[WebService(Namespace = "http://kitchenpc.com/schemas/")]
  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  [ScriptService]
  public class KitchenPC : System.Web.Services.WebService
  {
     [WebMethod]
     public LogonResult Logon(string username, string password)
     {
        //If username and password are not valid...
        throw new InvalidUsernameOrPasswordException();
     }
  }
  </code></pre>
  
  <p>When I would call it, if I passed in an invalid username and password, the <code>InvalidUsernameOrPasswordException</code> would be thrown and I could catch the exception in Javascript by looking at <code>error.get_exceptionType()</code>.  This is because the web service would serialize the exception info in JSON.</p>
  
  <p>However, once I upgraded to .NET 4.5, this broke.  Now, when I pass in an invalid username and password, I get the HTTP response:</p>
  
  <pre><code>HTTP/1.1 500 Internal Server Error
  Cache-Control: private
  Content-Type: application/json; charset=utf-8
  Server: Microsoft-IIS/7.5
  jsonerror: true
  X-AspNet-Version: 4.0.30319
  X-Powered-By: ASP.NET
  Date: Sat, 24 Nov 2012 22:42:33 GMT
  Content-Length: 91
  
  {"Message":"There was an error processing the request.","StackTrace":"","ExceptionType":""}
  </code></pre>
  
  <p>Basically, the exception type is lost and replaced with a generic error message.</p>
  
  <p>What caused this behavior to change, and is there still a way to return exception information in JSON?  Pretty much my entire API is designed to rely on this behavior.</p>