ASP.NET MVC CookieTempDataProvider.DeserializeTempData返回null [英] ASP.NET MVC CookieTempDataProvider.DeserializeTempData returns null

查看:304
本文介绍了ASP.NET MVC CookieTempDataProvider.DeserializeTempData返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用CookieTempDataProvider在一个post(实体更新)和get(实体列表)之间使用RedirectToAction方法传递一个基本消息。当使用默认的TempData实现这工作正常,但是当我使用基于cookie的版本从MVC Futures项目,TempData字典在重定向后是空的。这是因为TempDataDictionary从DeserializeTempData方法返回为null。我知道问题发生在什么行代码,我知道如何解决它,但我不能相信我是唯一一个有这个问题。

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.

也许我使用的是MVC Futures项目的错误版本,但我刚刚下载了 ASP.NET MVC v1.0源和问题肯定存在那里。有没有人使用CookieTempDataProvider,并且它为你工作?

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?

CookieTempDataProvider类的问题,我看到它是在第62行,它是投射反序列化对象作为TempDataDictionary,而不是作为IDictionary< string,object>。

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?

推荐答案

这里相同。使用组装后没有工作是从MVC期货。根据您的建议修改线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.

这篇关于ASP.NET MVC CookieTempDataProvider.DeserializeTempData返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆