views:

281

answers:

1

UPDATE: looks like I've misunderstood what TempData is for and what it isn't. It definitively shouldn't be used to "keep certain session-wide data" as I asked initially (see ASP.NET MVC TempData Is Really RedirectData why). I've modified the question accordingly.

Has anyone used CookieTempDataProvider for TempData storage? Are there any caveats to watch out for (apart from keeping the session storage small)? Any issues with using it on Web farms?

+1  A: 

I use the CookieTempDataProvider for our production web site and it seems to be working really well. We have a 2 server web farm. The site has been live for around 6 months, and we have experienced no issues, although the site does not get a lot of traffic. I use the CookieTempDataProvider to store status messages that are to be displayed when a view loads. For example:

  1. User edits a form and hits the save button. This is a post.
  2. In the POST action method, I save the data, then push a confirmation message into TempData. Then I issue a RedirectToAction, to a GET action.
  3. In the GET action method, I retrieve the message from the TempData and put it in the ViewData. Then I do my other data stuff and return the view.
  4. On the view I check if the model has a message, and if so, display it.

Things to note:

  1. I am using ASP.NET MVC 1.0.
  2. I am using MVC Futures 1.0.
  3. The CookieTempDataProvider did not work for me as is; I had to modify the code to get it working: see this post.
jimr