Reputation: 36490
I am confused about asp.net mvc seletor & filter.
As we know, there are 5 types of filters: authentication, authorization, action, result, exception.
However, there is another 'filter': action selector.
Base classes are different as well: ActionMethodSelectorAttribute and FilterAttribute
Can anyone tell me what is the difference between selector & common filter?
thanks.
Upvotes: 2
Views: 917
Reputation: 36490
Today i just red a material which illustrate this related question.
Inside the mvc framework, it goes something like this:
----ControllerFactory
----Controller selected and instantiated (With the help of Dependency Resolver)
----Call controller.Execute(RequestContext)
--------ActionInvoker (default: ControllerActionInvoker)
--------this.ActionInvoker.InvokeAction(ControllerContext, actionName)
------------Choose the action method (action selectors involved)
------------authentication & authorization filters
------------model binding
------------invoke action with action filters
------------authentication challenge (IAuthenticationFilter)
------------Execute result with result filters
----Controller dispose
See, the selector and filter are totally in different scope, even though they both are used in actionInvoker.
Upvotes: 0
Reputation: 10213
Action selectors simply determine which action to run (e.g. by the HTTP verb used for the request).
Filters some different goals - Action Filters run code before or after an action, exception filters runs code on exception, authentication filters are used for code realted to authentication, etc.
Upvotes: 1