ASP.NET更改会话ID

ASP.NET更改会话ID,asp.net,vb.net,cookies,global-asax,sessionid,Asp.net,Vb.net,Cookies,Global Asax,Sessionid,我必须更改ASP.NET 4.0应用程序的SessionID(通过Cookie的SessionID),使其在具有相同会话的2个域上运行(http://web1.local 及)。这将使项目与2个域保持同步 因此,页面将有一个带有“setkey.aspx/ashx”的iframe,它必须设置新的SessionID <iframe src="http://web1.local/SetKey.aspx?sid=<%=Session.SessionID%>" width="250" h

我必须更改ASP.NET 4.0应用程序的SessionID(通过Cookie的SessionID),使其在具有相同会话的2个域上运行(http://web1.local 及)。这将使项目与2个域保持同步

因此,页面将有一个带有“setkey.aspx/ashx”的iframe,它必须设置新的SessionID

<iframe src="http://web1.local/SetKey.aspx?sid=<%=Session.SessionID%>" width="250" height="100"></iframe>
<iframe src="http://web2.local/SetKey.aspx?sid=<%=Session.SessionID%>" width="250" height="100"></iframe>

有人正确运行了这段代码吗?

我已经尝试过在Global.asax的
应用程序的
处理程序中简单地设置cookie,它可以正常工作。这是C#,但你知道

void Application_EndRequest(object sender, EventArgs e)
{
   var ctx = HttpContext.Current;
   ctx.Response.Cookies.Remove("ASP.NET_SessionId");
   ctx.Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ctx.Request.QueryString("sid")));
}

最后的请求是我唯一没有尝试的方法:-)谢谢!它在Chrome、Firefox、Safari和Opera中工作,但在IE9中不起作用:-(嗯……我猜IE将其设置为只读。尝试通过添加
cookieName=“SessoinID”将cookie名称更改为其他名称(例如SessionID)到web.config文件中的
`标记。这应该可以修复IE。别忘了相应地更改代码。嗨,迭戈,更改cookiename不起作用:-(我将我的Testapp上载到了,也许有人知道如何让它在ie9中工作。使用SQL State Server是一种选择吗?嗨,不,因为SQL Server会花费很多性能。
void Application_EndRequest(object sender, EventArgs e)
{
   var ctx = HttpContext.Current;
   ctx.Response.Cookies.Remove("ASP.NET_SessionId");
   ctx.Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ctx.Request.QueryString("sid")));
}