In my project ,I have a class named AjaxOnlyAttribute that restricts Ajax requests to be shown if the request is not in ajax ... my code is like below:
public class AjaxOnlyAttribute : ActionMethodSelectorAttribute
{
public override bool IsValidForRequest(ControllerContext controllerContext, System.Reflection.MethodInfo methodInfo)
{
return controllerContext.RequestContext.HttpContext.Request.IsAjaxRequest();
}
}
and I use it in controllers like this:[AjaxOnly]
It works fine in asp.net mvc ,but it doesnt work in asp.net web api Can anyone help please?