In this article I will explain with an example, how to display / show / pass String Message from Controller to View in ASP.Net MVC 5.
The String message will be assigned to a ViewBag object in Controller and it will be later displayed on the View.
 
 
Displaying a Message from Controller to View in ASP.Net MVC
1. Inside the HomeController’s Index method, a ViewBag property named “Message” is set.
Display (Pass) String Message from Controller to View in ASP.Net MVC
 
2. The ViewBag property is displayed in the View named “Index” as shown below.
Display (Pass) String Message from Controller to View in ASP.Net MVC
 
3. Now press F5 to run the application and you should see a message displayed on page in browser.
Display (Pass) String Message from Controller to View in ASP.Net MVC
 
 
Downloads