特性Attribute 的使用
[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 的使用的更多相关文章
- [C#] 剖析 AssemblyInfo.cs - 了解常用的特性 Attribute
		剖析 AssemblyInfo.cs - 了解常用的特性 Attribute [博主]反骨仔 [原文]http://www.cnblogs.com/liqingwen/p/5944391.html 序 ... 
- [C#] C# 知识回顾 - 特性 Attribute
		C# 知识回顾 - 特性 Attribute [博主]反骨仔 [原文地址]http://www.cnblogs.com/liqingwen/p/5911289.html 目录 特性简介 使用特性 特性 ... 
- C# 知识特性 Attribute
		C#知识--获取特性 Attribute 特性提供功能强大的方法,用以将元数据或声明信息与代码(程序集.类型.方法.属性等)相关联.特性与程序实体关联后,可在运行时使用"反射"查询 ... 
- 区分元素特性attribute和对象属性property
		× 目录 [1]定义 [2]共有 [3]例外[4]特殊[5]自定义[6]混淆[7]总结 前面的话 其实attribute和property两个单词,翻译出来都是属性,但是<javascript高 ... 
- .Net内置特性Attribute介绍
		特性Attribute概述 特性(Attribute)是一种特殊的类型,可以加载到程序集或者程序集的类型上,这些类型包括模块.类.接口.结构.构造函数.方法.字段等,加载了特性的类型称之为特性的目标. ... 
- 【点滴积累】通过特性(Attribute)为枚举添加更多的信息
		转:http://www.cnblogs.com/IPrograming/archive/2013/05/26/Enum_DescriptionAttribute.html [点滴积累]通过特性(At ... 
- 理解特性attribute 和 属性property的区别 及相关DOM操作总结
		查一下英语单词解释,两个都可以表示属性.但attribute倾向于解释为特质,而property倾向于解释私有的.这个property的私有解释可以更方便我们下面的理解. 第一部分:区别点 第一点: ... 
- 如何获取类或属性的自定义特性(Attribute)
		如何获取类或属性的自定义特性(Attribute) 问题说明: 在ActiveRecord或者其他的ORM等代码中, 我们经常可以看到自定义特性(Attribute)的存在(如下面的代码所示) [Pr ... 
- C# 知识特性 Attribute,XMLSerialize,
		C#知识--获取特性 Attribute 特性提供功能强大的方法,用以将元数据或声明信息与代码(程序集.类型.方法.属性等)相关联.特性与程序实体关联后,可在运行时使用“反射”查询特性,获取特性集合方 ... 
- c#特性attribute:
		特性是被编译到metadata中, 是提供给反射用的. 特性attribute:1 什么是attribute,和注释有什么区别 2 声明和使用attribute3 使用attribute完成扩展4 ... 
随机推荐
- Android点击Button按钮的四种事件监听方法总结
			首先我们在activity_main.xml里面先定义一个Button空间 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <RelativeLayout xmlns:a ... 
- mybatis--常见的错误
			1.没有在configuration.xml配置对应的sql配置文件 错误: Error updating database. Cause: java.lang.IllegalArgumentExce ... 
- ios开发中全局变量设置和调用方法
			ios开发中,全局变量设置和调用方法如下:在AppDelegate.h文件中设置全局变量:@interface ***AppDelegate{NSString *myName;}@property ( ... 
- VMVare 桥接上网
			桥接模式设置小解: 第1步 虚拟机下fedora安装好后,打开VM虚拟机的菜单栏,单击编辑------虚拟网络编辑器,选择“主机虚拟网络 映射”标签,然后把VMnet0 手动选择为你本地的物理网卡(要 ... 
- Linux FTP 服务器配置简单说明
			一. FTP 说明 linux 系统下常用的FTP 是vsftp, 即Very Security File Transfer Protocol. 还有一个是proftp(Profession ftp ... 
- IM 之 融云
			官方网站:http://www.rongcloud.cn 官方开发文档:http://www.rongcloud.cn/docs/ IM 融云 之 开发基础概念 IM 融云 之 通讯能力库API IM ... 
- 破解&屏蔽防止嵌入框架代码 top.location != self.location
			<script type="text/javascript"> if (top.location != self.location) top.location = se ... 
- js函数对象
			函数是进行模块化程序设计的基础,编写复杂的Ajax应用程序,必须对函数有更深入的了解. javascript中的函数不同于其他的语言,每个函数都是作为一个对象被维护和运行的.通过函数对象的性质,可以很 ... 
- Delphi操作XML
			Delphi操作XML Delphi操作XMl,只要使用 NativeXml.我是用的版本是4..NativeXML的使用方法比较简单,但是功能很强大. XE2的话,要在simdesign.inc后面 ... 
- centos 用户管理
			3.使用命令管理账户 useradd 选项 用户名//添加新用户 usermod 选项 用户名//修改已经存在的用户 userdel -r 用户名//删除用户表示自家目录一起删除. grou ... 
