What is ViewData in ASP.NET MVC?

Updated Apr 28, 2026

Short answer

ViewData is a dictionary for passing data from controller to view.

Deep explanation

ViewData stores data using key-value pairs and requires type casting.

Real-world example

Passing simple data to views.

Common mistakes

  • Type casting errors.

Follow-up questions

  • What is ViewBag?
  • Why ViewData?

More ASP.NET MVC interview questions

View all →