36

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

what is different?

2 Answers 2

41

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
Sign up to request clarification or add additional context in comments.

1 Comment

Actually, it's the Mvc filter that can have an order specified and Web API one can't
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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.