欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

form身份驗(yàn)證通過后,只能用FormsAuthentication.RedirectFromLoginPage

 更新時(shí)間:2009年03月05日 00:38:18   作者:  
form身份驗(yàn)證通過后,只能用FormsAuthentication.RedirectFromLoginPage
直接用Response.Redirect("default.aspx")的話當(dāng)然驗(yàn)證失敗,因?yàn)槟愀緵]有建立身份驗(yàn)證票。FormsAuthentication.RedirectFromLoginPage方法,會(huì)自動(dòng)完成很多功能的。如完成生成身份驗(yàn)證票,寫回客戶端,瀏覽器重定向等一系列的動(dòng)作。當(dāng)然完成這些功能并不是只有FormsAuthentication.RedirectFromLoginPage方法才能辦到,相反如果需要帶角色信息的驗(yàn)證則只能采用其他辦法。
我門可采用手動(dòng)添加身份驗(yàn)證票
1.
 
復(fù)制代碼 代碼如下:

FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket (1,"coffee",DateTime.Now, DateTime.Now.AddMinutes(20), false,UserRoles,"/") ;

注:UserRoles不知道就寫""
2.加密序列化
復(fù)制代碼 代碼如下:

string HashTicket = FormsAuthentication.Encrypt (Ticket) ;

3.生成cookie
復(fù)制代碼 代碼如下:

HttpCookie UserCookie = new HttpCookie(FormsAuthentication.FormsCookieName, HashTicket) ;
cookie.Domain = ".jb51.net";

4.身份驗(yàn)證票Cookie輸出到客戶端
復(fù)制代碼 代碼如下:

Response.Cookies.Add(UserCookie)

5.重定向
復(fù)制代碼 代碼如下:

Response.Redirect (Context.Request["ReturnUrl"]) ;

相關(guān)文章

最新評(píng)論