Joao
Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by...
In my humble opinion the application should not return the object
Pending
because that resource does not exist in the case of a 404 HTTP response code. This is something you could consider while designing your application.
If you want to stick to the exception you need to make sure your application handles it, see this example: https://learn.microsoft.com/en-us/aspnet/web-api/overview/error-handling/exception-handling17 replies
Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by...
@HAHOOS your application is probably not handling the exception thrown in the controller. Is there a specific benefit to throw an exception in the example given?
You could, as alternative return an HttpNotFoundResult:
return new HttpNotFoundResult("optional description");
Or in .NET latest versions return ProblemDetails
or a NotFound
objects.17 replies