Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Web API Throw Exception

I'm trying to throw an exception from my Web API controller. The problem is that my JavaScript code doesn't get any data back.

throw new HttpResponseException(HttpStatusCode.NoContent);

In my jQuery ajax function I don't get anything back. I get undefined back from the ajax call. So basically what is the proper way of handling errors from the server?

like image 260
Lasse Vabe Rolstad Avatar asked Dec 21 '25 16:12

Lasse Vabe Rolstad


1 Answers

I feel very stupid right now, i tried a diffrent StatusCode and now i actully got some data back. I assumed every statusCode woulde return some value. This status code literaly returns NoContent.

like image 65
Lasse Vabe Rolstad Avatar answered Dec 24 '25 06:12

Lasse Vabe Rolstad