Sessions can be maintained in MVC by three ways: tempdata, viewdata, and viewbag. Temp data - This helps to maintain data when you move from one controller to another controller or from one action to another action. In other words, when you redirect, tempdata helps to maintain data between those redirects. It internally uses session variables.
View data - It helps to maintain data when you move from controller to view.
View Bag - This is a dynamic wrapper around view data. When you use Viewbag type, casting is not required. It uses the dynamic keyword internally.
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Sessions can be maintained in MVC by three ways: tempdata, viewdata, and viewbag.
Temp data - This helps to maintain data when you move from one controller to another controller or from one action to another action. In other words, when you redirect, tempdata helps to maintain data between those redirects. It internally uses session variables.
View data - It helps to maintain data when you move from controller to view.
View Bag - This is a dynamic wrapper around view data. When you use Viewbag type, casting is not required. It uses the dynamic keyword internally.