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