As per the ASP.NET website
The ASP.NET MVC framework includes several action filters:
Also, there is a type of filter in MVC called "Authorization filter".
I am confused whether [Authorize] attribute is an Action filter or Authorization filter? And when will it be executed ?
Authorization filters allow you to perform authorization tasks for an authenticated user. A good example is Role based authorization. ASP.NET MVC 4 also introduced a built-in AllowAnonymous attribute. This attribute allows anonymous users to access certain Controllers/Actions.
Authorization filters are used to authenticate whether the user requested action method in the controller is authorized to access or not and for validating properties of the request. Authorization filters run before any other filter. Generally, we will use authorization filters like as shown below.
What is the difference between Authorize Action filter and Authorization filter?
None.
That documentation is apparently incorrect (and if you note in the table of contents, it is for version 1 and 2 of MVC, so it is also out of date).
AuthorizeAttribute
inherits IAuthorizationFilter
, so it is in fact an authorization filter, not an action filter. There is no Authorization action filter in MVC.
Note that for MVC 3 to MVC 5 you should refer to the up-to-date Filtering in ASP.NET MVC documentation in the future.
And when will it be executed ?
As per MSDN:
Filters run in the following order:
- Authorization filters
- Action filters
- Response filters
- Exception filters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With