This is my javascript code and my controller looks like this
but whenever there is an error or Exception it always goes to success callback What am i missing here
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 {
}
},
error: function (response, status, err) {
}};
$('#registration').ajaxSubmit(options);
[HttpPost]
public Task<HttpResponseMessage> Register()
{
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;
}