Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC CookieTempDataProvider: any experience?

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?

like image 232
Igor Brejc Avatar asked Jul 29 '09 08:07

Igor Brejc


People also ask

How good is ASP NET MVC?

asp.net mvc is nice for people whom do not really have the time to properly create an MVC app in a webforms environment and also to those whom do not have the time to architect a better solution. in conlcusion, asp.net mvc is good but there is a much better way of doing it and finally, MVC is NOT a technology.

Is ASP .NET MVC?

MVC with ASP.NETASP.NET gives you a powerful, patterns-based way to build dynamic websites using the MVC pattern that enables a clean separation of concerns.

Does .NET core has MVC?

The ASP.NET Core MVC framework is a lightweight, open source, highly testable presentation framework optimized for use with ASP.NET Core. ASP.NET Core MVC provides a patterns-based way to build dynamic websites that enables a clean separation of concerns.


1 Answers

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.
like image 75
jimr Avatar answered Oct 20 '22 03:10

jimr