After a series of exercises showing the data:
MVC 5 uses ViewData (objects) to display data http://www.cnblogs.com/insus/p/3377178.html
MVC 5 uses ViewData (model) to display data http://www.cnblogs.com/insus/p/3377217.html
MVC 5 uses ViewBag (objects) to display data http://www.cnblogs.com/insus/p/3377663.html
MVC 5 strongly Typed views (strongly typed view) http://www.cnblogs.com/insus/p/3377826.html
Is the data passing between the current controller and the view, what if it is necessary to pass from one controller to another? MVC provides an object that is the same as the session, which is called TempData.
The following insus.net also want to list a simple example to show everyone to see.
Originally this exercise was done last night, found that the vs2013 RC trial expired,
Only download the official version, until today to the VS upgrade, download, no need uninstall RC version, directly installed, it will be upgraded on the RC version.
After the upgrade, it was found that there were few changes in MVC 5 when creating model,controll and view.
In the controller write good tempdata:
Then write a link in index.cshtml, in order to let the user click on this link, can link to pagea () this action to.
@Html. ActionLink ("Show to Page A", "PageA")
The TempData data can be used in the pagea.cshtml:
The following live action demo.
You need to know the target view, and the data is passed from one view to another.