Open Closed

Overrride AbpExceptionFilter #8911


User avatar
0
maria_ruiz created
  • ABP Framework version: v9.0.4

  • UI Type: Blazor WASM

  • Database System: EF Core (SQL Server)

  • Tiered (for MVC) or Auth Server Separated (for Angular): no

  • Exception message and full stack trace:

  • Steps to reproduce the issue:

Hi, we have a problem override AbpExceptionFilter.

We have this class override the methods
image.png

In the host module, replace the services,
for the class DefaultExceptionToErrorInfoConverter it works

image.png

in application initialization we added this code to verified if replace the class, returns SmcExceptionFilter
image.png

And in program host class also debugging and check
image.png

But when the exception is triggered, the debugging point stops in the class of AbpExceptionFilter

Any points to check why this might happen?


2 Answer(s)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, instead of removing the IAsyncExceptionFilter registration from DI container, you can directly replace the related exception filter like this:

    context.Services.Configure<MvcOptions>(options =>
    {
        options.Filters.ReplaceOne(
            f => f is ServiceFilterAttribute fa && fa.ServiceType == typeof(AbpExceptionFilter),
            new ServiceFilterAttribute(typeof(YourAbpExceptionFilter))
        );
    
        options.Filters.ReplaceOne(
            f => f is ServiceFilterAttribute fa && fa.ServiceType == typeof(AbpExceptionPageFilter),
            new ServiceFilterAttribute(typeof(YourAbpExceptionPageFilter))
        );
    });
    

    After adding this configuration, you can delete the last two service replacement in the shared code and it should work as expected.

    Regards.

  • User Avatar
    0
    maria_ruiz created

    It works, thanks a lot

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 13, 2025, 04:08