我必須更改ASP.NET 4.0應用程序(SessionID通過Cookie)的SessionID,使其在具有相同Session的兩個域(http://web1.local和http://web2.local)上運行。這將保持項目在2個域中同步。ASP.NET更改SessionID
因此,Page將具有帶「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>
在Session.Start中Session已經被填充,所以SessionID通過來自同一個Broeser的幾個請求保持靜態。
我發現了幾個職位,主要使用SessionIDManager.SaveSessionID,但我可以得到他們沒有工作。
我發現了這段代碼,但是我要在哪裏調用它? (global.asax/default.aspx/setjey.aspx/ashx?)
Dim Redirected As Boolean = False
Dim Added As Boolean = False
Dim SID = Request.QueryString("sid")
If Not String.IsNullOrEmpty(SID) AndAlso SID.Length = 24 Then
Dim SM As New SessionIDManager
SM.InitializeRequest(HttpContext.Current, False, True)
SM.RemoveSessionID(HttpContext.Current)
SM.SaveSessionID(HttpContext.Current, SID, Redirected, Added)
End If
有沒有人得到此代碼來正確運行?
會使用SQL狀態服務器是一個選項嗎? http://support.microsoft.com/kb/317604 – 2012-03-02 18:33:37
嗨,不,因爲SQL Server會花費太多的性能。 – Christoph 2012-03-05 13:00:47