当前位置: 首页>>代码示例>>C#>>正文


C# ActionDescriptor.IsDefined方法代码示例

本文整理汇总了C#中System.Web.Mvc.ActionDescriptor.IsDefined方法的典型用法代码示例。如果您正苦于以下问题:C# ActionDescriptor.IsDefined方法的具体用法?C# ActionDescriptor.IsDefined怎么用?C# ActionDescriptor.IsDefined使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Mvc.ActionDescriptor的用法示例。


在下文中一共展示了ActionDescriptor.IsDefined方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Redirect

 /// <summary>
 /// 重定向方法 有两种情况:如果是Ajax请求,则返回 Json字符串;如果是普通请求,则 返回重定向命令
 /// </summary>
 /// <param name="IsNoLogin">判断是未登录还是没有权限</param>
 /// <param name="url"></param>
 /// <param name="action"></param>
 /// <returns></returns>
 public ActionResult Redirect(bool IsLogin, ActionDescriptor action)
 {
     //如果Ajax请求没有权限,就返回 Json消息
     if (action.IsDefined(typeof(AjaxRequestAttribute), false)
     || action.ControllerDescriptor.IsDefined(typeof(AjaxRequestAttribute), false))
     {
         if (IsLogin)
         {
             return RedirectAjax("nologin", null, null, "/Login/Login/Index");
         }
         else
         {
             Uri MyUrl = Request.UrlReferrer;
             string url = MyUrl.ToString();
             return RedirectAjax("nopermission", "您没有权限访问此页面", null, url);
         }
     }
     else//如果 超链接或表单 没有权限访问,js代码
     {
         if (IsLogin)
         {
             ContentResult result = new ContentResult();
             //跳回登陆页面
             result.Content = "<script type='text/javascript'>alert('您还没有登陆呦!');parent.location='" +"/Login/Login/Index"+ "'</script>"; ;
             return result;
         }
         else
         {
             //返回上一级URL
             Uri MyUrl = Request.UrlReferrer;
             string url = MyUrl.ToString();
             ContentResult result = new ContentResult();
             result.Content = "<script type='text/javascript'>alert('您没有权限访问此页面!');window.location='" + url + "'</script>";
             return result;
         }
     }
 }
开发者ID:fangyz,项目名称:FinalabBMS,代码行数:44,代码来源:OperateContext.cs

示例2: Redirect

 /// <summary>
 /// 重定向方法 有两种情况:如果是Ajax请求,则返回 Json字符串;如果是普通请求,则 返回重定向命令
 /// </summary>
 /// <returns></returns>
 public ActionResult Redirect(string url, ActionDescriptor action)
 {
     //如果Ajax请求没有权限,就返回 Json消息
     if (action.IsDefined(typeof(AjaxRequestAttribute), false)
     || action.ControllerDescriptor.IsDefined(typeof(AjaxRequestAttribute), false))
     {
         return RedirectAjax("nologin", "您没有登陆或没有权限访问此页面~~", null, url);
     }
     else//如果 超链接或表单 没有权限访问,则返回 302重定向命令
     {
         return new RedirectResult(url);
     }
 }
开发者ID:wanghaoguan,项目名称:Final-Web,代码行数:17,代码来源:OperateContext.cs

示例3: HasAllowAnonymousAttribute

 private bool HasAllowAnonymousAttribute(ActionDescriptor actionDescriptor)
 {
     var allowAnonymousType = typeof(AllowAnonymousAttribute);
     return (actionDescriptor.IsDefined(allowAnonymousType, true) ||
         actionDescriptor.ControllerDescriptor.IsDefined(allowAnonymousType, true));
 }
开发者ID:blerimj,项目名称:ScaffR-Generated,代码行数:6,代码来源:ClaimsAuthorizeModule.cs


注:本文中的System.Web.Mvc.ActionDescriptor.IsDefined方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。