: 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
source share