Global exception handling in ASP.NET Core rc2 filter works without exception

I only have a database registration registrar:

   loggerFactory.AddDatabaseLogger(logRepository,serviceProvider,LogLevel.Error);

And after that, all my unhandled errors are logged in the database. When I add my custom error filter, all unhandled errors are recorded twice.

 services.AddMvc(config =>
        {
            config.Filters.Add(new CustomExceptionFilter(_loggerFactory));
        });

Isn't a custom global exception filter created with the latest version of ASP.NET 5 RC2?

+4
source share
1 answer

Exception filters are an MVC concept, and since unhandled exceptions can occur even outside of MVC, using ExceptionFilters may not be enough.

, , ExceptionHandlerMiddleware. . : app.UseExceptionHandler(errorHandlingPath: "/Home/Error"); Error . , :

var exceptionHandlerFeature = HttpContext.Features.Get<IExceptionHandlerFeature>();
var exception = exceptionHandlerFeature.Error;

, , , . , , .

exceptionContext.ExceptionHandled = true;

+4

All Articles