Monday, December 9, 2013

What is TempData, ViewBag, and ViewData?



  • TempData: A typical use for TempData is to pass data from one action method to another action method, via a redirect. After the desired object is read from TempData, the ASP.NET runtime disposes of the object in the TempData dictionary
  • ViewBag: stores data that will be used in the corresponding view
  • ViewData: Same as ViewBag, but ViewBag is dynamically typed. ViewData is the underlying mechanism for ViewBag

No comments:

Post a Comment