A view requests information from the model that it uses to generate an output representation to the user.
First Add Home Controller in MVC Project.
ViewBag & ViewData is a mechanism to pass data from controller to view.
To pass data from controller to a view, it's always a good practice to use strongly typed view models.
We use "@" symbol to switch between html and C# code.

Enter View Name. and Click Add Button.

Now Create Index.cshtml file in View/Home Folder.
Write Following code into Home Controller.

Now open Index.cshtml file. and write following code.

Now Run Project.(Ctrl+F5)

Post a Comment