Skip to main content

Posts

Showing posts with the label TempData Keep() vs. Peek()

ViewData vs. ViewBag vs. TempData.Peek() vs. Keep() in ASP.Net MVC

TempData Keep() vs. Peek() Hello everyone, I am going to share the difference between ViewData vs. ViewBag vs. TempData and also TempData.Keep() vs. TempData.peek() methods in ASP.Net MVC. The details about it as given below. ViewData :  View Data  is a dictionary object and use to maintain the data between the controller to View. It's also require to typecasting and It check null value each time.   It become null if redirect occurs. ViewBag :  View bag  is a dynamic property and use to maintain the data between the controller to View. It's not require to typecasting and check null value.   It become null if redirect occurs. TempData : Temp Data  is a dictionary object and use to maintain the data between the controller to controller and one action to other action. It use to check null value each time. The TempData.keep() and TempData.peek() methods are use to read the data without deletion the current re...