In what order are filters executed in asp.net mvc

前端 未结 2 1482
有刺的猬
有刺的猬 2020-12-02 18:20

In MVC we can decorate action methods with different filters like

[HttpPost]
[Authorize]
public ActionResult mymethod(){}

HttpPost

2条回答
  •  借酒劲吻你
    2020-12-02 18:53

    To save you some time, this is how you set the order:

    [MyCustomContextFilter(Order=1)]
    

    The index is 0 based, so you can do 0, 1, 2, etc...

    It should be noted that just because a filter is on the base class doesn't tell MVC to apply it first :(.

提交回复
热议问题