日期:2014-05-19  浏览次数:20661 次

Login控件登陆成功的问题
.net2.0里面的Login控件用起来比较方便
问题是,我现在要在Page_Load中设置已经通过了验证(用于别人的站点登陆成功即可访问我的站点),该如何弄?
AuthenricateEventArg好像有个Authenricated是用来判断用户已经登陆成功的,但那是写在OnAuthenricate事件里的呀。我是要写在Page_Load里面的

------解决方案--------------------
默认的Login控件会根据Sql Server Express 2005 mdf文件里的Membership表里的数据验证用户。

当然也可以不用Sql Server数据库,只要Login1_Authenticate事件里访问别的数据库,然后在e.Authenticated = true;就可以了。
如:
Login1.Authenticate += new AuthenticateEventHandler(Login1_Authenticate);
// 这个也可以在属性面板里生成。

//自定义验证
void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
using(OracleConnection conn = new OracleConnection())
{
...

}
if(用户名和密码匹配的记录存在)
{
e.Authenticated = true;
}
else
{
e.Authenticated = false;
}
}