How to Handle Exeption in ASP.NET Web API

When there are unhandled exceptions in the Web API controller class, most of the actual exceptions are indicated by the HTTP 500 status code or also known as the Internal Server Error. This error does not provide useful information to the client so lets tweak it up a bit to display. You can fine tune and customize your HTTP errors to be sent to the client’s browser in a more user-friendly way.


With this tweak, clients won’t be seeing that ugly generic “Internal Server Error” message. Using only the HttpResponseException class, you can return meaningful error to your clients.


Read the rest of the story here:

Leave a Reply

Your email address will not be published. Required fields are marked *