Creating A New Page (View)

How this page (View) was created.


Make sure the application is stopped in Visual Studio.

Not Running (Good)


Running (Bad)


Open the Controllers Folder in the Solution Explorer. Click on the Home Controller (c).

This is the Home Contoller Class (C). It is contained between namespace Noah.Controllers { public class HomeController : Controller { ..... } }


Give the controller a new Action. This Action is named CreateNewView. The Action returns a view (a new page).


Right click on the name of the Action in the controller. A menu will appear. Click Add View.


Click Add


In the menu that appears type the name of the action, in this case CreateNewView. Click Add


The CreateNewView.cshtml file was automatically generated and populated into the solution. The CreateNewView view automatically opens in Visual Studio. The empty page is ready for new code.


Adding Page To Menu


In the views folder, open the shared folder and click on _Layout.cshtml file.


Copy the code for a list item.


Paste the code in the nav bar list. Change asp-action="CreateNEwView", to the name of the new action. Update the name to be displayed on the menu. Save and run the application.



Save the changes and refresh the broswer. The new item will appear in the menu.