ASP.NET MVC CookieTempDataProvider: any experience?

UPDATE: It looks like I misunderstood what TempData is and what is not. It should definitely not be used to “save certain session data,” as I first asked (see ASP.NET MVC TempData - This is Really Redirected Data Why). I changed the question accordingly.

Has anyone used CookieTempDataProvider to store TempData? Are there any warnings that need to be followed (other than storing storage for the session)? Any problems using it in web farms?

+6
cookies asp.net-mvc
source share
1 answer

I use CookieTempDataProvider for our website and it seems to work very well. We have a web farm with two servers. The site has been working for 6 months, and we did not have any problems, although the site does not receive much traffic. I use CookieTempDataProvider to store status messages that should be displayed when the view loads. For example:

  • The user edits the form and clicks the save button. This is a message.
  • In the POST action method, I save the data and then send a confirmation message to TempData. Then I throw out a RedirectToAction, into a GET action.
  • In the GET action method, I get the message from TempData and put it in ViewData. Then I do other data and return the view.
  • In the view, I check if the model has a message, and if so, display it.

Notes:

  • I am using ASP.NET MVC 1.0.
  • I am using MVC Futures 1.0.
  • CookieTempDataProvider did not work for me as it is; I had to change the code to make it work: see this post .
+5
source share

All Articles