,以后每次获取用户资料都是根据这个登录用户名来取用户资料(具体参考AspNetForums.Users.GetUser()、AspNetForums.Users.GetLoggedOnUsername()和AspNetForums.ForumsHttpModule.Application_AuthenticateRequest(Object source, EventArgs e)方法,ForumContext.Current.UserName = context.User.Identity.Name;),所以我们如果要让CnForums共享主系统的登录验证,可以在主系统登录成功后,也记录当前登录的Username,也就是Login.cs中的FormsAuthentication.SetAuthCookie(userToLogin.Username, autoLogin.Checked),在CnForums中,只要表中有当前登录的这个用户,就会认为当前这个用户是登录过的(在CnForums的HttpModule里面,如果当前登录的Username在表中没记录,则会自动注销,所以一定要保持用户表的同步)。还有要注意就是Forms验证不能跨域,所以就要让CnForums免虚拟目录安装,具体方法可搜索以前的帖子。
相关文章: