Quantcast
Channel: ASP.NET Core Web API exception handling - Stack Overflow
Browsing all 13 articles
Browse latest View live

Answer by ws_ for ASP.NET Core Web API exception handling

use middleware or IExceptionHandlerPathFeature is fine. there is another way in eshop create a exceptionfilter and register it public class HttpGlobalExceptionFilter : IExceptionFilter { public void...

View Article



Answer by Ilya Chernomordik for ASP.NET Core Web API exception handling

Latest Asp.Net Core (at least from 2.2, probably earlier) has a built-in middleware that makes it a bit easier compared to the implementation in the accepted answer: app.UseExceptionHandler(a =>...

View Article

Answer by Arjun for ASP.NET Core Web API exception handling

Well accepted answer helped me a lot but i wanted to pass HttpStatusCode in my middleware to manage error status code at runtime. According to this link i got some idea to do the same. So i merged the...

View Article

Answer by CountZero for ASP.NET Core Web API exception handling

Firstly, thanks to Andrei as I've based my solution on his example. I'm including mine as it's a more complete sample and might save readers some time. The limitation of Andrei's approach is that...

View Article

Answer by Ihar Yakimush for ASP.NET Core Web API exception handling

To Configure exception handling behavior per exception type you can use Middleware from NuGet packages: Community.AspNetCore.ExceptionHandling.NewtonsoftJson for ASP.NET Core 2.0...

View Article


Answer by Edward Brey for ASP.NET Core Web API exception handling

First, configure ASP.NET Core 2 Startup to re-execute to an error page for any errors from the web server and any unhandled exceptions. public void Configure(IApplicationBuilder app,...

View Article

Answer by Andrei for ASP.NET Core Web API exception handling

Exception Handling Middleware After many experiments with different exception handling approaches I ended up using middleware. It worked out the best for my ASP.NET Core Web API application. It handles...

View Article

Answer by Ashley Lee for ASP.NET Core Web API exception handling

Your best bet is to use Middleware to achieve logging you're looking for. You want to put your exception logging in one middleware and then handle your error pages displayed to the user in a different...

View Article


ASP.NET Core Web API exception handling

I started using ASP.NET Core for my new REST API project after using regular ASP.NET Web API for many years. I don't see a good way to handle exceptions in ASP.NET Core Web API. I tried to implement...

View Article


Answer by Alex Klaus for ASP.NET Core Web API exception handling

Here is the official guideline from Microsoft covering WebAPI and MVC cases for all versions of .NET.For Web API it suggests redirecting to a dedicated controller end-point to return ProblemDetails. As...

View Article

Answer by pepa for ASP.NET Core Web API exception handling

If you want set custom exception handling behavior for a specific controller, you can do so by overriding the controllers OnActionExecuted method.Remember to set the ExceptionHandled property to true...

View Article

Answer by Chris Halcrow for ASP.NET Core Web API exception handling

A simple way to handle an exception on any particular method is:using Microsoft.AspNetCore.Http;...public ActionResult MyAPIMethod(){ try { var myObject = ... something; return Json(myObject); } catch...

View Article

Answer by r.pedrosa for ASP.NET Core Web API exception handling

By adding your own "Exception Handling Middleware", makes it hard to reuse some good built-in logic of Exception Handler like send an "RFC 7807-compliant payload to the client" when an error...

View Article

Browsing all 13 articles
Browse latest View live




Latest Images