Using ViewData in ASP.NET CORE 3.0

ViewData is Use to pass data from controller to View only and its value cannot be retained.
ViewData is derived from ViewDataDictionary which is dictionary type and ViewData required typecasting.
We are going add Controller with Name Demo4 with Index action method inside that we are going to declare ViewData with a string value.

using Microsoft.AspNetCore.Mvc;

namespace WebApplication2.Controllers
    public class Demo4Controller : Controller
        public IActionResult Index()
            ViewData["Message"] = "Hi Message";
            return View();


Message: - @ViewData["Message"]