这是我的 javascript 代码,我的控制器看起来像这样
,但是每当出现错误或异常时,它总是会转到成功回调我在这里缺少什么
Javascript
var options = {
iframe: true,
type: 'post',
url: "api/Registration/Register",
data: { "data": jsonData },
dataType: 'json',
success: function (responseText, statusText, xhr, $form)
{
if (statusText == 'success') {
}
else { //code == 'FAIL'
}
},
error: function (response, status, err) {
}};
$('#registration').ajaxSubmit(options);
[HttpPost]
public Task<HttpResponseMessage> Register()
{
//create task object and read server data
try
{
var response = new HttpResponseMessage
{
StatusCode = HttpStatusCode.OK,
Content = new StringContent(JsonConvert.SerializeObject(assistedRegResponse.Response))
};
return response;
}
catch (Exception ex){ throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));}
return task;
}