Asp.Net Mvc in ViewData and ViewBag

ViewData and the difference ViewBag

1, ViewData a type dictionary, the dictionary assignment manner mode, reads the corresponding key value by a value, ViewData [ "myName"]

2, ViewBag dynamic type, property assignment can be added directly use ViewBag.myName

3, ViewBag ViewData only valid in the current and the Action, equivalent to View

4, ViewData and values ViewBag can visit each other, because the implementation of ViewBag contains ViewData
---------------------
Author: liangyaomu
Source: CSDN
Original: https : //blog.csdn.net/liangyaomu/article/details/78976150
Disclaimer: This article is a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin www.cnblogs.com/zcwfb/p/10967465.html