.NET Framework用户处理机制(FORMS)
2004-11-20 19:28
295 查看
一.在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;
相关文章推荐
- 搜索引擎注册“邪门”大法
- 工作!!工作!!!工作!!!!
- 内存对齐问题
- 使用Hibernate的项目中对VO的理解
- 关于Gmail的二三事
- 无聊
- 在C#中运用SQLDMO备份和恢复Microsoft SQL Server数据库
- 留言版
- CCtrlView类的实现
- 目前用的几个Firefox插件
- 在SQL Server中保存和输出任意类型的文件
- VB开发中背景音乐的制作
- 访问Google快照的小窍门
- 免费空间(zz http://ifstar.net/)
- tomcat配置技巧(转载)
- DELPHI实现摄像头拍照
- 成长中必须知道的20个故事
- VC常用知识 (自 hongyang1980 的 Blog)
- 人在异乡
- 呵呵