一.在Web.config中声明:
<authentication mode="Forms">
<forms name="News" path="/" loginUrl="/News/Modules/Users/Login.aspx"
protection="All" timeout="30">
</forms>
</authentication>
二.正常进入页面:
Context.User = user;
FormsAuthentication.SetAuthCookie(tbEmail.Text,true);
其中user是生成的一个用户对象,它拥有userID,userName,EmailAddress等属性。
三.页面间转换:
首先在Global.asax中加入:
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
if (Request.IsAuthenticated == true)
{
Context.User = new Dong.WebModules.Accounts.Business.DongPrincipal(Context.User.Identity.Name);
}
}
然后在另外的页面里取值并进行其它操作:
Dong.WebModules.Accounts.Business.User currentUser =
new Dong.WebModules.Accounts.Business.User((Dong.WebModules.Accounts.Business.DongPrincipal)Context.User);
tbUserName.Text = currentUser.UserName;
tbEmail.Text = currentUser.EmailAddress;
<authentication mode="Forms">
<forms name="News" path="/" loginUrl="/News/Modules/Users/Login.aspx"
protection="All" timeout="30">
</forms>
</authentication>
二.正常进入页面:
Context.User = user;
FormsAuthentication.SetAuthCookie(tbEmail.Text,true);
其中user是生成的一个用户对象,它拥有userID,userName,EmailAddress等属性。
三.页面间转换:
首先在Global.asax中加入:
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
if (Request.IsAuthenticated == true)
{
Context.User = new Dong.WebModules.Accounts.Business.DongPrincipal(Context.User.Identity.Name);
}
}
然后在另外的页面里取值并进行其它操作:
Dong.WebModules.Accounts.Business.User currentUser =
new Dong.WebModules.Accounts.Business.User((Dong.WebModules.Accounts.Business.DongPrincipal)Context.User);
tbUserName.Text = currentUser.UserName;
tbEmail.Text = currentUser.EmailAddress;