What is the lifespan of each storage area in ASP.net MVC

I have seen some explanations for these, but nothing that really compares where they start, end or overlap, or good examples of their use.

What is the life expectancy of each of the following data collections? And am I missing any?

  • Application
  • Session
  • ViewData li>
  • TempData li>
+4
source share
1 answer

: while the application is running. Your application may be automatically shut down and restarted by the server for various reasons.

session: while the user is actively using your site. this is usually determined by the cookies that ASP.NET sends to give each user a unique identifier that expires after a while. There are many ways to configure and customize to meet different needs.

viewdata: while the current request is being processed. this is used to send data from the controller to the view for immediate rendering and thus is not saved

tempdata: until the value is returned to the initial state OR until the end of processing the next request in the session or when the session ends / expires, whichever comes first. this is intended to be used to move data from one controller to another when you send a redirect

+11
source

Source: https://habr.com/ru/post/1334122/


All Articles