Home »  Dot Net MVC Tutorial »  MVC ViewData

MVC ViewData

MVC ViewData

  • MVC ViewData helps to maintain data when you move from controller to view.
  • MVC ViewData Used to pass data from controller to corresponding view.
  • Short life means value becomes null when redirection occurs. This is because their goal is to provide a way to communicate between controllers and views. It is a communication mechanism within the server call.
  • MVC ViewData is a dictionary of objects that is derived from ViewDataDictionary class and is accessible using strings as keys.
  • MVC ViewData requires typecasting for complex data type and check for null values to avoid error.

MVC ViewData Example :

  public ActionResult Index()  {      ViewData["SiteName"] = "QuickToStudy";      return View();  }  

MVC ViewData In View:

MVC ViewData
Contact Us| About Us| Terms| Privacy Policies
Powered by Lorquins Technologies© 2017 QuickToStudy.com. All Rights Reserved