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

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;
            }
        }
原文地址:https://www.cnblogs.com/byfcumt/p/6846600.html