MVC - Add a new page

by
Jeremy Canfield |
Updated: March 20 2020
| MVC articles
In this example, let's add a new page named FAQs under Home, so that we have a page such as http://www.example.com/Home/FAQs.
Controller
- In Solution Explorer, expand Controllers and select the HomeController.cs
- Add the following markup to the HomeController.cs file:
public ActionResult FAQs(){
ViewBag.Message = "FAQs";
return View();
}
View
- In Solution Explorer, expand View.
- Right-click on the Home folder and select Add > View
- Name the View FAQs and select Add
You can now publish the site, navigate to http://www.example.com/Home/FAQs, and your FAQs page should be displayed.
Did you find this article helpful?
If so, consider buying me a coffee over at