How to register a global filter with mvc 6, asp.net 5

前端 未结 2 767
南方客
南方客 2020-12-18 20:33

I\'m trying to register a filter in a simple mvc application. I haven\'t even really written anything yet outside of the basic filter to test with. I\'m using VS 2015 RC and

相关标签:
2条回答
  • 2020-12-18 20:40

    With Beta 8 it is now done via AddMvc as follows:

    services.AddMvc(options =>
    {
        options.Filters.Add(new YouGlobalActionFilter());
    });
    
    0 讨论(0)
  • 2020-12-18 20:44

    Example of how you can do it in MVC 6

    public void ConfigureServices(IServiceCollection services)
    {
       services.AddMvc();
       services.ConfigureMvc(options =>
       {
          options.Filters.Add(new YouGlobalActionFilter());
       }
    }
    
    0 讨论(0)
提交回复
热议问题