|
快乐的天堂</a>
<a target ="_blank"
href="MyTransfer.aspx?goto=http://My_Computer_Name/FormTest/Public/AddCookie_F.aspx">
大大的火坑</a>
MyTransfer.aspx 的代码:
private void Page_Load(object sender, System.EventArgs e)
{
//获取身份验证票
System.Web.Security.FormsAuthenticationTicket tk =((System.Web.Security.FormsIdentity)User.Identity).Ticket;
string key = System.Web.Security.FormsAuthentication.Encrypt(tk); //每次加密后的字串都是不同的
string next = Request["goto"]; //将要跳转的 URL
Response.Redirect(url+"?CookieTicket="+key); //跳转至下一页面
}
AddCookie_D.aspx、AddCookie_E.aspx、AddCookie_F.aspx 这三张页面的代码:
string key = Request["CookieTicket"]; //已加密的 Cookie 文本
if(key != null && key !="")
{
System.Web.HttpCookie ck = new HttpCookie(System.Web.Security.FormsAuthentication.FormsCookieName,key);
ck.Path=System.Web.Security.FormsAuthentication.FormsCookiePath;
ck.Expires = System.DateTime.Now.AddYears(100);
上一篇:ASP.NET 安全认证(三): 用Form 表单认证实现单点登录
下一篇:水晶报表的5种表格设计模式
|