public class AjaxOnlyAttribute : ActionMethodSelectorAttribute { public override bool IsValidForRequest(RouteContext routeContext, ActionDescriptor action) { return routeContext.HttpContext.Request.IsAjaxRequest(); } }