【发布时间】:2015-05-12 11:58:05
【问题描述】:
我使用 ServiceStack 框架在 ASP.net MVC5 中开发了我的应用程序。在我的应用程序中,单击按钮时,我会调用返回数据的 ajax 服务器。
this.LoadData = function(){
$.ajax({
url: '@Url.Action("SearchCustomer", "Customer")',
cache: false,
type: 'GET',
contentType: 'application/json',
data: { 'IndexNo': this.IndexNo },
success: function (result) {
},
error: function (xhr, status, error) {
}
});
}
在某些情况下,我的服务层会抛出异常(我理解应该将其序列化到 Response DTO 的 ResponseStatus 对象中)。在上述 ajax 调用的错误函数中,我想检索我的服务层抛出的自定义异常消息。我怎样才能做到这一点?上面的状态和错误包含序列化的 ResponseStatus 信息,即“内部服务器错误”、错误代码 500 等。我想要的是我的服务层抛出的自定义错误消息。
【问题讨论】:
标签: jquery asp.net-mvc-5 asp.net-ajax servicestack