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"
My custom exception has a property called "FieldErrors" that doesn't not show up in the return. Here's the code for that class:
[Serializable]
[XmlRootAttribute(Namespace = "http://www.mydomain.com/", IsNullable = false)]
public class ValidationException : Exception
{
public List<string> FieldErrors { get; set; }
public ValidationException(string message = null, Exception innerException = null) : base(message: message, innerException: innerException)
{
this.FieldErrors = new List<string>();
}
}
My goal is to get the "FieldErrors" property to show up in the json response.