ASP.NET MVC: Enforce AJAX request on an action
I'm looking for a way to enforce a controller's action to be accessed only via an AJAX request. What is the best way to do this before the action method is called? I want to refactor the following from my action methods: if(Request.IsAjaxRequest()) // Do something else // return an error of some sort What I'm envisioning is an ActionMethodSelectorAttribute that can be used like the [AcceptVerbs] attribute. I have no experience crating such a custom attribute though. bmancini Create an ActionFilter that fires OnActionExecuting public class AjaxActionFilter : ActionFilterAttribute { public