Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

How to add custom mvc filter in AbpModule by ASP.NET Core #3126


User avatar
0
goldstar25 created

Hi,How to add custom mvc filter in AbpModule by ASP.NET Core?There has no method look this:

private static void AddFilters(MvcOptions options)
        {
            options.Filters.AddService(typeof(AbpAuthorizationFilter));
            options.Filters.AddService(typeof(AbpAuditActionFilter));
            options.Filters.AddService(typeof(AbpValidationActionFilter));
            options.Filters.AddService(typeof(AbpUowActionFilter));
            options.Filters.AddService(typeof(AbpExceptionFilter));
            options.Filters.AddService(typeof(AbpResultFilter));
        }

3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can do it in ConfigureServices method of Startup.cs. Include it like this:

    services.AddMvc(options =>
    {
        ........
        options.Filters.Add(typeof(AbpAuthorizationFilter));
        ........
    });
    
  • User Avatar
    0
    goldstar25 created

    But,How to set it in AbpModuleā€˜s PreInitialize methond?

  • User Avatar
    0
    goldstar25 created

    I give up this way,I had to override the OnActionExecuting method inside the controller .