Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Web.Mvc.ActionFilterAttribute vs System.Web.Http.Filters.ActionFilterAttribute

i see that there are two version of ActionFilterAttribute class.
System.Web.Mvc.ActionFilterAttribute and System.Web.Http.Filters.ActionFilterAttribute

what is different?

like image 636
Majid Hazari Avatar asked Sep 26 '12 16:09

Majid Hazari


People also ask

Which filter will be execute at last using ASP.NET MVC?

Exception Filters − Exception filters are the last type of filter to run. You can use an exception filter to handle errors raised by either your controller actions or controller action results.


1 Answers

The System.Web.Http one is for Web API; the System.Web.Mvc one is for previous MVC versions.

You can see from the source that the Web API version has several differences.

  • It has OnResultExecuting and OnResultExecuted handlers ("Called by the ASP.NET MVC framework before/after the action result executes.")
  • It can be executed asynchronously
  • It does not let you specify an order of execution
like image 131
McGarnagle Avatar answered Sep 21 '22 15:09

McGarnagle