我正在使用Webmatrix進行身份驗證的ASP.Net MVC 4應用程序。我在我的web.config文件模式設置爲「SQLServer」的URL中的會話標識
<sessionState mode="SQLServer" cookieless="true" allowCustomSqlDatabase="true"
sqlConnectionString="Data Source=server;Initial Catalog=ASPState;Persist
Security Info=True;User ID=user;Password=password"
timeout="2880" sqlCommandTimeout="10" />
我可以看到正在填充ASPState的數據庫以下,但我仍然獲得在URL中的會話ID。當我嘗試通過Chrome訪問它時,出現許多重定向錯誤。當我通過IE瀏覽器訪問它的作品,即使我看到它重定向(儘管會話ID是在URL中),但錯誤,當我嘗試用下面的錯誤登錄:
Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.
我還沒有做出任何定製到Webmatrix,這都是默認設置。我需要會話ID,以保持不在網址和使用數據庫像我有它在web.config
文件中設置
此消息告訴您,您嘗試添加無法序列化的會話類 - 例如Dictionary <>無法保存在會話或其他您可能不使用[序列化]類的列表上,關鍵詞。 – Aristos