views:

194

answers:

2

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?

A: 

FWIW... I just ran into the same issue. Your solution fixed it for me as well. Not sure why no others have reported this problem. Thanks for your helpful post!

Ian
+1  A: 

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.

Michael Paladino
Yup. MVC 2.0 and bug on line 62 is still 100% intact.(And was causing the exact same problems/issues where TempData wouldn't be intact following a Redirect.)
Michael K Campbell