Click here to Skip to main content
15,908,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
I have two controllers one for login and other for Adding details.
Now on successful login I am extracting phone number and passing to to "Add" controller.
I am able to do this by using Tempdata variable but not with ViewData or ViewBag???

Second for for "Add" controler I have "Add" view with mobile number field. At the sametime I have to populate that field. How can it be done.

Similarly there are other controlers in which I have to pass the mobile number.
Posted

1 solution

ViewBag and ViewData are not persisted between page requests, they are only for passing data from controller to its view. TempData uses the Session, and the Session is persisted for the entirety of the user's visit, however TempData deletes the data from the Session when you read it so it's a one-use variable. If you need the data kept around for multiple uses then use the Session rather than TempData.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900