using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.ActionConstraints;
using Microsoft.AspNetCore.Routing;
using System;
namespace EC.Web
{
///
/// 版 本 EasyCode EC管理后台
/// Copyright (c) 2019-present EC管理有限公司
/// 创建人:tobin
/// 日 期:2019.09.12
/// 描 述:仅允许Ajax操作
///
[AttributeUsage(AttributeTargets.Method)]
public class AjaxOnlyAttribute : ActionMethodSelectorAttribute
{
///
/// 验证请求有效性
///
///
///
///
public override bool IsValidForRequest(RouteContext routeContext, ActionDescriptor action)
{
return routeContext.HttpContext.Request.IsAjax();
}
}
}