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

form身份驗證通過后,只能用FormsAuthentication.RedirectFromLoginPage

 更新時間:2009年03月05日 00:38:18   作者:  
form身份驗證通過后,只能用FormsAuthentication.RedirectFromLoginPage
直接用Response.Redirect("default.aspx")的話當然驗證失敗,因為你根本沒有建立身份驗證票。FormsAuthentication.RedirectFromLoginPage方法,會自動完成很多功能的。如完成生成身份驗證票,寫回客戶端,瀏覽器重定向等一系列的動作。當然完成這些功能并不是只有FormsAuthentication.RedirectFromLoginPage方法才能辦到,相反如果需要帶角色信息的驗證則只能采用其他辦法。
我門可采用手動添加身份驗證票
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.身份驗證票Cookie輸出到客戶端
復(fù)制代碼 代碼如下:

Response.Cookies.Add(UserCookie)

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

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

相關(guān)文章

最新評論