ASP.NET Web API Exception Throwing

I am trying to throw an exception from my web API controller. The problem is my JavaScript code is not returning any data.

throw new HttpResponseException(HttpStatusCode.NoContent);


In my jQuery ajax function I am getting nothing. I am getting undefined back from the ajax call. So basically what is the correct way to handle errors from the server?


source to share

1 answer

I feel very stupid now, I tried diffent StatusCode and now I got some data again. I assumed that each statusCode would return some value. This alphabetic status code returns NoContent.



All Articles