34

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

what is different?

tereško
  • 58,060
  • 25
  • 98
  • 150
Majid Hazari
  • 694
  • 6
  • 13

2 Answers2

40

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
McGarnagle
  • 101,349
  • 31
  • 229
  • 260
6

System.Web.Mvc.ActionFilterAttribute is intended for use with ASP.NET MVC. System.Web.Http.Filters.ActionFilterAttribute is intended for use with ASP.NET Web API.

MVC is web applications, Web API is HTTP services.

Their msdn pages are System.Web.Mvc.ActionFilterAttribute and System.Web.Http.Filters.ActionFilterAttribute

MushinNoShin
  • 4,695
  • 2
  • 32
  • 46