mvc Session为什么丢失?
环境:mvc 1.0
问题:在系统启动时会产生一个Session. Session["admin_ID"] = "aa27ec10-d9d4-43d9-96f6-7cfb0d5099ca";
但是在执行了下面代码后,Session就会丢失。
- C# code
-
[AcceptVerbs(HttpVerbs.Post)] public ActionResult GenerateVerifyModel(FormCollection formCollection) { ... return File(zipPath, "application/x-zip-compressed"); }
百思不得其解,为什么下载文件后就会丢失session?
后来在Web.config中进行了如何设置:
<sessionState mode="StateServer" cookieless="false" timeout="60" stateConnectionString="tcpip=127.0.0.1:42424"
stateNetworkTimeout="3600" />
但是运行时提示:
Unable to serialize the session state. Please note that non-serializable objects or MarshalByRef objects are not permitted when session state mode is 'StateServer' or 'SQLServer'.
看这个提示应该是说Session中的内容无法序列化,可是Session中只有一个GUID啊。Session["admin_ID"] = "aa27ec10-d9d4-43d9-96f6-7cfb0d5099ca";
请高手指点。
致力于SharePoint开发.
QQ:28748451.