📜  如何在 asp.net core 中检测 ajax 请求 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:05.886000             🧑  作者: Mango

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