我试图在两个web应用程序之间共享会话,这两个应用程序都托管在同一台服务器上.一个是a.net 2.0 web表单应用程序,另一个是as.net 3.5 MVC2应用程序.
两款应用的会话设置如下:
<sessionState
mode="StateServer"
stateConnectionString="tcpip=127.0.0.1:42424"
/>
在webform应用程序中,我将会话密钥发布到MVC应用程序:
protected void LinkButton1_Click(object sender, EventArgs e)
{
Session["myvariable"] = "dan";
string sessionKey = HttpContext.Current.Session.SessionID;
//Followed by some code that posts sessionKey to the other application
}
然后我在MVC应用程序中接收它,并try 使用相同的会话,如下所示:
[HttpPost]
public void Recieve(string sessionKey )
{
var manager = new SessionIDManager();
bool redirected;
bool IsAdded;
manager.SaveSessionID(HttpContext.ApplicationInstance.Context, Id, out redirected, out IsAdded);
var myVar = Session["myvariable"];
}
密钥已发布,但会话似乎未加载到MVC应用程序中,即sessionKey为空.我想做的事能做到吗?