码迷,mamicode.com
首页 > Web开发 > 详细

MVC绕过登陆界面验证时HttpContext.Current.User.Identity.Name取值为空问题解决方法

时间:2017-05-12 19:10:13      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:end   blog   void   取值   解决   user   tpc   entity   use   

Global.asax界面添加如下方法:

void FormsAuthentication_Authenticate(object sender, FormsAuthenticationEventArgs e)
        {
            string UserName = this.Context.Request.QueryString["UserName"];
            if (!string.IsNullOrEmpty(UserName))
            {  
                FormsAuthentication.SetAuthCookie(UserName, true);
                e.User = new GenericPrincipal(new GenericIdentity(UserName), null);
                return;
            }
        }

 

MVC绕过登陆界面验证时HttpContext.Current.User.Identity.Name取值为空问题解决方法

标签:end   blog   void   取值   解决   user   tpc   entity   use   

原文地址:http://www.cnblogs.com/byfcumt/p/6846600.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!