Where does TempData get stored in the ASP.NET MVC Framework (more specifically, ASP.NET MVC 2)? Is it stored at server-side, or is sent to the client?
2 Answers
By default TempData uses the ASP.NET Session as storage. So it is stored on the server (InProc
is the default). But you could define other ASP.NET Session state modes: StateServer and SqlServer. You could also write a custom TempData provider and handle the storage yourself if you don't want to use the ASP.NET Session.

- 1,023,142
- 271
- 3,287
- 2,928
-
Thank you very much. I will investigate more about the ASP.NET session state modes, that's new for me. – Guillermo Gutiérrez Feb 21 '13 at 14:26
-
1This seems not to be true anymore for ASP.NET Core. "The cookie-based TempData provider is enabled by default. To enable the session-based TempData provider... " https://learn.microsoft.com/en-us/aspnet/core/fundamentals/app-state?view=aspnetcore-6.0 – Benyom Dec 13 '21 at 15:35
It is stored in session storage, but there is one crucial difference between TempData
and Session
:
TempData
is available only for a user’s session, so it persists only till we have read it and gets cleared at the end of an HTTP Request.
A scenario that fits the usage of TempData
, is when data needs to persist between two requests – a redirect scenario. Another scenario I can think of is to return an error message after a POST operation fails.

- 55,877
- 15
- 127
- 148
-
Thanks man, I wish I could select more than one answer as accepted. – Guillermo Gutiérrez Feb 21 '13 at 14:26
-
1*TempData is available only for a user’s session, so it persists only till we have read it and gets cleared at the end of an HTTP Request.* Sessions last longer than HTTP requests. So is *TempData is available only for a user's session* correct? – ta.speot.is Nov 17 '13 at 23:34