title: Writing a filter that applies to both MVC and Web API requests
body: <p>My ASP.NET application uses both ASP.NET MVC for serving web pages and ASP.NET Web API for serving AJAX requests that originate from those web pages.</p>
  
  <p>I would like certain things such as checking if the request is authenticated, setting appropriate things in the HttpContext to happen regardless of which kind of request I'm dealing with. </p>
  
  <p>I'm currently having to write two classes </p>
  
  <p>1) one that inherits - System.Web.Mvc.ActionFilterAttribute for MVC requests
  2) one that inherits - System.Web.Http.Filters.ActionFilterAttribute for Web API requests </p>
  
  <p>Is there a way to apply a filter that runs for both MVC and API requests to the website? or is going via the old http modules the recommended way for such a use case? </p>