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.
|
- using System;
- using System.Web.Mvc;
-
- namespace Learun.Application.Web
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创建人:陈彬彬
- /// 日 期:2017.03.08
- /// 描 述:仅允许Ajax操作
- /// </summary>
- [AttributeUsage(AttributeTargets.Method)]
- public class AjaxOnlyAttribute : ActionMethodSelectorAttribute
- {
- /// <summary>
- /// 初始化仅允许Ajax操作
- /// </summary>
- /// <param name="ignore">跳过Ajax检测</param>
- public AjaxOnlyAttribute(bool ignore = false)
- {
- Ignore = ignore;
- }
-
- /// <summary>
- /// 跳过Ajax检测
- /// </summary>
- public bool Ignore { get; set; }
-
- /// <summary>
- /// 验证请求有效性
- /// </summary>
- /// <param name="controllerContext">控制器上下文</param>
- /// <param name="methodInfo">方法</param>
- public override bool IsValidForRequest(ControllerContext controllerContext, System.Reflection.MethodInfo methodInfo)
- {
- if (Ignore)
- return true;
- return controllerContext.RequestContext.HttpContext.Request.IsAjaxRequest();
- }
- }
- }
|