How do I get certain code to execute before every single controller action in ASP.NET MVC 2?

后端 未结 2 1623
情书的邮戳
情书的邮戳 2020-12-23 16:57

I want to check some things about the state of the session, the user agent, etc, and possibly take action and return a special view BEFORE a controller method gets a chance

2条回答
  •  春和景丽
    2020-12-23 17:28

    One way you can do this is to redirect to a different ActionMethod to show the view. Code example is in this discussion:

    Redirecting to specified controller and action in asp.net mvc action filter

提交回复
热议问题