You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
634 B
21 lines
634 B
using System;
|
|
using System.Web.Mvc;
|
|
|
|
namespace NFine.Web
|
|
{
|
|
[AttributeUsage(AttributeTargets.Method)]
|
|
public class HandlerAjaxOnlyAttribute : ActionMethodSelectorAttribute
|
|
{
|
|
public bool Ignore { get; set; }
|
|
public HandlerAjaxOnlyAttribute(bool ignore = false)
|
|
{
|
|
Ignore = ignore;
|
|
}
|
|
public override bool IsValidForRequest(ControllerContext controllerContext, System.Reflection.MethodInfo methodInfo)
|
|
{
|
|
if (Ignore)
|
|
return true;
|
|
return controllerContext.RequestContext.HttpContext.Request.IsAjaxRequest();
|
|
}
|
|
}
|
|
}
|