ASP.NET MVC CookieTempDataProvider.DeserializeTempData 返回 null
我一直在尝试使用 CookieTempDataProvider 使用 RedirectToAction 方法在 post(实体更新)和 get(实体列表)之间传递基本消息。当使用默认的 TempData 实现时,效果很好,但是当我使用 MVC Futures 项目中基于 cookie 的版本时,TempData 字典在重定向后为空。这是因为 TempDataDictionary 从 DeserializeTempData 方法返回为 null。我确切地知道问题发生在哪一行代码上,并且我知道如何解决它,但我不敢相信我是唯一遇到此问题的人。
也许我使用了错误版本的 MVC Futures 项目,但我刚刚下载了 ASP.NET MVC v1.0 源,问题肯定存在于此。还有其他人使用 CookieTempDataProvider吗?它对您有用吗?
据我所知,CookieTempDataProvider 类的问题在于第 62 行,它将反序列化对象转换为 TempDataDictionary,而不是 IDictionary
还有其他人看到这个问题吗,还是只有我一个人看到这个问题?
I've been trying to use CookieTempDataProvider to pass a basic message between a post (entity update) and a get (entity list) using the RedirectToAction method. When using the default TempData implementation this works fine, however when I use the cookie-based version from the MVC Futures project, the TempData dictionary is empty after the redirect. This is because the TempDataDictionary is returned as null from the DeserializeTempData method. I know exactly what line of code the problem occurs on, and I know how to fix it, but I can't believe that I'm the only one to have this problem.
Maybe I'm using the wrong version of the MVC Futures project, but I've just downloaded the ASP.NET MVC v1.0 source and the problem definitely exists there. Does anyone else use CookieTempDataProvider, and does it work for you?
The problem with the CookieTempDataProvider class, as I see it, is on line 62, where it is casting the deserialized object as TempDataDictionary instead of as IDictionary<string, object>. When I make this change, everything works perfectly.
Anyone else see this problem, or is it just me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
同样在这里。按照 MVC Futures 的原样使用汇编后不起作用。按照您的建议更改第 62 行解决了问题。感谢您发帖。
Same here. Didn't work after using assembly as is from MVC Futures. Changing line 62 as you suggested fixed the problem. Thanks for posting.