title: How to serialize a custom exception to json in c#
body: <p>I have a c# web service that I call using jquery ajax.  It works fine except when a custom exception is throw inside the web method.  For some reason, the XmlHttpResponse objects responseText only has the base Exception class's properties.  So I end up with a json object with the following properties: "ExceptionType", "Message", and "StackTrace"</p>
  
  <p>My custom exception has a property called "FieldErrors" that doesn't not show up in the return.  Here's the code for that class:</p>
  
  <pre><code>[Serializable]
  [XmlRootAttribute(Namespace = "http://www.mydomain.com/", IsNullable = false)]
  public class ValidationException : Exception
  {
      public List&lt;string&gt; FieldErrors { get; set; }
      public ValidationException(string message = null, Exception innerException = null) : base(message: message, innerException: innerException) 
      {
          this.FieldErrors = new List&lt;string&gt;();
      }
  }
  </code></pre>
  
  <p>My goal is to get the "FieldErrors" property to show up in the json response.</p>