Exception Handling in ASP.NET Web Api 2
问题 Problem: I need to handle web api 2 exceptions and return a rich object with the correct status code (401 for Unauthorized, 404 for ContentNotFound, etc) and some extra information as the content. Moreover, I need the content to look like a serialized Exception object (have the message , exceptionMessage , stackTrace , ... properties). Suggested Solutions: Create custom exception classes and writing a custom exception filter to apply to any controller's action. this custom exception filters