Where does TempData get stored?

本秂侑毒 提交于 2019-11-30 17:20:46

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!