TempData
Session
TempData allow us to persisting data for the duration of single subsequent request.
Session is able to store data much more long time, until user session is not expire.
ASP.net MVC will automatically expire the value of tempdata once consecutive request returned the result (it means, it alive only till the target view is fully loaded).
Session will be expire after the session time out occurred.
It valid for only current and subsequent request only
It valid for all requests.
TempData has Keep method to retention the value of TempData.
Example
TempData.Keep()
TempData.Keep(“EmpName”)
NA
TempData internally stored the value in to Session variable.
Session varible are stored in SessionStateItemCollection object (Which is exposed through the HttpContext.Session property of page).
It is used to stored only one time messages like validation messages, error messages etc.
It is used to stored long life data like user id, role id etc. which required throughout user session.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: