asp.net face questions Summary 1 (To be continued ....)

1, TempData \ ViewBag \ ViewData difference in MVC?

  A: The page object by value, there are three objects can pass.

  

  (. 1) TempData in Session, the Controller each time execution of the request, will first obtain from the Session TempData, then Session clear, complete data acquisition TempData, while stored in the internal dictionary object, but each entry in the set access time after deleted from the dictionary table. Specific code level, the acquisition process is read by TempData SessionStateTempDataProvider.LoadTempData Session ControllerContext method from the data, then clears the Session, it is only cross TempData Controller transmitted once.

 (2) ViewBag ViewData only valid in the current and the Action, equivalent to View

 (. 3) and values ​​ViewData ViewBag can access each other, because the implementation of ViewBag contains ViewData

 

(To be continued ....)

Guess you like

Origin www.cnblogs.com/schangxiang/p/11279123.html