I am calling a controller method from the client using jQuery's ajax
.
$.ajax({
url: "/Services/VendorServices.asmx/SendVendorRequestNotifications",
type: 'POST',
contentType: "application/json",
dataType: "json",
data: JSON.stringify({ vendorModel: info }),
timeout: requestTimeOut,
success: function (data) {
// Success
},
error: function (jqXHR, textStatus, errorThrown) {
// Error: Would like to display meaningful message here!
}
});
If my SendVendorRequestNotifications
throws an exception, I'd like to display an error message on the client side. However, I can't seem to get a good message to display to the user.
textStatus:
error
errorThrown:
Internal Server Error
jqXHR.responseText:
{"Message":"One or more errors occurred.","StackTrace":" at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task'1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task'1.get_Result()","ExceptionType":"System.AggregateException"}
As you can see, none of this is useful data. I'd like to be able to gather a more meaningful message on the server and have it available to the error
handler of the $.ajax
call.
Is this possible?