文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Login控件的问题,希望有更好的解决办法

Login控件的问题,希望有更好的解决办法

时间:2010-09-17  来源:YoungSin

.Net 2.0带的Login控件很好用,用过很多次的,这次却发现了一个问题

因为可以允许用户使用不同的用户名(系统用户名,邮箱,NT帐号等)登录,后台通过用户表都会找到系统用户名

用于设置验证cookie; 但是问题来了,HttpContext.Current.User.Identity.Name的值始终是Login控件中输入的用户名

而不是通过转换后的系统用户名,即使强制设定了 HttpContext.Current.User 的值, 

把e.Authenticated 设为 true后,在验证的函数Login1_Authenticate结束以后,都会自动被改为Login的输入用户名 

没办法,为了得到正确的 HttpContext.Current.User.Identity.Name值,只好如此做

 

 

     protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)

    {         string pasUserName;         bool bolR = WSC_Permission.LoginValidateByEntries(Login1.UserName, Login1.Password, out pasUserName);         if (bolR)         {             FormsAuthentication.SetAuthCookie(pasUserName, this.Login1.RememberMeSet);

 

            LogManager.Write(LogActionType.Login,                             "The user use this account["                             + this.Login1.UserName + "]  to log on.");
            Server.Transfer("FrameMain.aspx");         }         else             MessageBox.Show(Resources.Resource.MSG_ERR_CHECK_PASSWORD);
        e.Authenticated = false;      }

 

 

 

 

 

 

 

 

 

代码不够优美,不知道有没有更好的解决办法

 

相关阅读 更多 +
排行榜 更多 +
猎鹿人神枪手中文版内置MOD菜单

猎鹿人神枪手中文版内置MOD菜单

飞行射击 下载
拔锚少女

拔锚少女

棋牌卡牌 下载
战争荣耀传奇

战争荣耀传奇

角色扮演 下载