[IdentityAuthorize]   
        public ActionResult Index()
        {
            return View("~/Views/Index.cshtml");
        }

[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
    public class IdentityAuthorizeAttribute : ActionFilterAttribute, IActionFilter
    {
        /// <summary>
        /// 验证是否登陆,没有登陆跳转到 登陆页
        /// </summary>
        /// <param name="filterContext">上下文</param>
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            try
            {
                if (!Identity.IsAuthenticated)
                {
                    string url = HttpContext.Current.Request.Url.ToString();
                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.Write("<script>window.top.location='" + Config.WapLoginUrl + "?backurl=" + url + "'</script>");
                    HttpContext.Current.Response.End();
                }
                base.OnActionExecuting(filterContext);
            }
            catch (Exception exception)
            {
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Write(exception.Message);
                HttpContext.Current.Response.End();
            }
        }
    }

特性Attribute 的使用的更多相关文章

  1. [C#] 剖析 AssemblyInfo.cs - 了解常用的特性 Attribute

    剖析 AssemblyInfo.cs - 了解常用的特性 Attribute [博主]反骨仔 [原文]http://www.cnblogs.com/liqingwen/p/5944391.html 序 ...

  2. [C#] C# 知识回顾 - 特性 Attribute

    C# 知识回顾 - 特性 Attribute [博主]反骨仔 [原文地址]http://www.cnblogs.com/liqingwen/p/5911289.html 目录 特性简介 使用特性 特性 ...

  3. C# 知识特性 Attribute

    C#知识--获取特性 Attribute 特性提供功能强大的方法,用以将元数据或声明信息与代码(程序集.类型.方法.属性等)相关联.特性与程序实体关联后,可在运行时使用"反射"查询 ...

  4. 区分元素特性attribute和对象属性property

    × 目录 [1]定义 [2]共有 [3]例外[4]特殊[5]自定义[6]混淆[7]总结 前面的话 其实attribute和property两个单词,翻译出来都是属性,但是<javascript高 ...

  5. .Net内置特性Attribute介绍

    特性Attribute概述 特性(Attribute)是一种特殊的类型,可以加载到程序集或者程序集的类型上,这些类型包括模块.类.接口.结构.构造函数.方法.字段等,加载了特性的类型称之为特性的目标. ...

  6. 【点滴积累】通过特性(Attribute)为枚举添加更多的信息

    转:http://www.cnblogs.com/IPrograming/archive/2013/05/26/Enum_DescriptionAttribute.html [点滴积累]通过特性(At ...

  7. 理解特性attribute 和 属性property的区别 及相关DOM操作总结

    查一下英语单词解释,两个都可以表示属性.但attribute倾向于解释为特质,而property倾向于解释私有的.这个property的私有解释可以更方便我们下面的理解. 第一部分:区别点 第一点:  ...

  8. 如何获取类或属性的自定义特性(Attribute)

    如何获取类或属性的自定义特性(Attribute) 问题说明: 在ActiveRecord或者其他的ORM等代码中, 我们经常可以看到自定义特性(Attribute)的存在(如下面的代码所示) [Pr ...

  9. C# 知识特性 Attribute,XMLSerialize,

    C#知识--获取特性 Attribute 特性提供功能强大的方法,用以将元数据或声明信息与代码(程序集.类型.方法.属性等)相关联.特性与程序实体关联后,可在运行时使用“反射”查询特性,获取特性集合方 ...

  10. c#特性attribute:

    特性是被编译到metadata中,  是提供给反射用的. 特性attribute:1 什么是attribute,和注释有什么区别 2 声明和使用attribute3 使用attribute完成扩展4 ...

随机推荐

  1. VS2010打开旧版本MFC工程无对话框

    解决方案: 左侧有个"资源视图",打开,里面就能找得到对话框,如果没有资源视图,就在菜单的视图选项里打开资源视图!

  2. D Vitamin - the wonder vitamin

    原文 Be healthier and happier by spending time in the sun In the dead of winter,we don't typically thi ...

  3. leetcode-005 reorder list

    1 package leetcode; public class ReOrderList { public void reorderList(ListNode head) { if(head==nul ...

  4. 更改Windows Live Writer默认日志与草稿保存路径

    目的:把保存Windows Live Writer的日志与草稿文件夹My Weblog Posts移动到E:\Blog\路径下 用mklink命令,创建E:\Blog\路径下的My Weblog Po ...

  5. 【Xilinx-LVDS读写功能实现】-00-开始

    最近用到了一款LVDS接口的摄像头,640*480灰度图像,数据速率为600Mbps,位宽10bit,DDR双边沿采样. 实现数据的采集需要用到FPGA内的SERDES模块,现在已经仿真通过了,等到上 ...

  6. IOS web app一些实用的属性设置

    IOS对safari私有的属性很多,虽然很多不为人知但是却很实用.掌握好这些属性对web app和混合app的开发会很有帮助. 1.format-detection[telephone=no] 是否自 ...

  7. mybatis:"configuration" must match "(properties?,settings?,typeAliase.....

    在运行mybatis配置文件的时候,出现错误: mybatis:"configuration" must match "(properties?,settings?,ty ...

  8. 网站安全配置(Nginx)防止网站被攻击(包括使用了CDN加速之后的配置方法)

    原文链接:http://www.bzfshop.net/article/176.html 网站被攻击是一个永恒不变的话题,网站攻击的方式也是一个永恒不变的老套路.找几百个电脑(肉鸡),控制这些电脑同时 ...

  9. PHP cookie禁用时session 方案

    在PHP中使用过SESSION的朋友可能会碰到这么一个问题,SESSION变量不能跨页传递.这令我苦恼了好些日子,最终通过查资料思考并解决了这个问题.我认为,出现这个问题的原因有以下几点: 1.客户端 ...

  10. Java 获取url参数

    1. 方式一:使用HttpServletRequest对象 String id = arg0.getParameter("id"); mv.addObject("id&q ...