0
我已經建立了一個ASP.NET會話狀態服務器上的SQL數據庫:ASP.NET會話狀態服務器:存儲的對象爲NULL
<sessionState timeout="60" allowCustomSqlDatabase="true" mode="SQLServer" sqlConnectionString="..." />
我有一個默認的錯誤重定向:
<customErrors mode="On" defaultRedirect="~/Error.aspx" />
的Global.asax.cs:
private void Application_Error(object sender, EventArgs e)
{
SomeSessionObj sessionObj = new SomeSessionObj();
sessionObj.SomeProperty1 = true;
sessionObj.SomeProperty2 = new Blabla();
HttpContext.Current.Session["FooBar"] = sessionObj;
}
Error.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
SomeSessionObj sessionObj = HttpContext.Current.Session["FooBar"] as SomeSessionObj;
// sessionObj is NOT NULL
// sessionObj.SomeProperty1 is false
// sessionObj.SomeProperty2 is NULL
}
SomeSessionObj和SomeProperty類都被標記爲可序列化。
沒有狀態服務器(inProc)它按預期工作。
在此先感謝。