Global Action Filter in ASP.NET MVC

Is it possible to create a global action filter that will be automatically applied to all actions in all controllers in an ASP.NET MVC application? I want something like "before_filter" defined in ApplicationController in Ruby on Rails.

Thank you for your help.

+5
source share
2 answers

It really depends on what you want to do with it. In many scenarios, the previous vucetica and Adeel answers will be what you really want to do. However, none of them meets the specified criteria: it is automatically applied to all actions / controllers .

- , BeginRequest Global.asax. . MSDN.

- 27 2010 : ScottGu blogged about MVC 3 Preview 1, , . Global.asax .

+3

.

+3

All Articles