web.config中使用authentication控制全局登陆后,用户二次访问时如何获取它的信息?

来源:百度知道 编辑:UC知道 时间:2024/06/28 00:45:07
<authentication mode="Forms">
<forms name="erp" loginUrl="login.aspx" protection="None"></forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
以上是写在web.config中的语句,我都能理解。

配合login.aspx.cs中,如果通过验证执行下面这条语句,永久储存cookie。
System.Web.Security.FormsAuthentication.RedirectFromLoginPage(UserID.Text, true);

问题是,系统是怎么处理这个Cookie的。
打个比方,用户第一次访问时,被带到login.aspx要求登陆,

第二次再来访问的时候,直接就能进入它要的页面了。
这样的话,我怎样才能获得他的用户信息呢?

谢谢高手!

去查询下NET权限登陆。在百度里搜。网上N多代码。 这是2003年的登陆技术。很老的了。
现在都用自定义比较多点。

登录代码

private void Button1_Click(object sender,System.EventArgs e)
{
if(System.Web.Security.FormsAuthentication.Authenticate(this.TextBox1.Text,This.TextBox2.Text)
{
// System.Web.Security.FormsAuthentication.SetAuthCookie(this.TextBox1.Text,true);//此方法需重定向
// Response.Redirect("WebForm1.aspx");
System.Web.Security.FormsAuthentication.RedirectFromLoginPage(this.TextBox1.Text,false);//此方法不需要重定向,直接转到原访问页
}
else
{
Response.Redirect("login.aspx");
}
}