How to add a new page in ASP.NET mvc4?

15,706

In ASP.NET MVC you work with Models, Controllers and Views. Controllers are classes containing methods called Actions. Each Action is used as an entry point for a given user request. This Action will perform any necessary processing with the model and return a view. So basically you will start with defining a Controller (if not already done) and add Actions to it:

public class HomeController: Controller
{
    public ActionResult Index()
    {
        return View();
    }

    public ActionResult SomeAction()
    {
        return View();
    }
}

Then you right click on the Action name and select the Add->View option which will create a new View for the given Action in the respective ~/Views folder.

I would recommend that you start by going through the basic tutorials here: http://asp.net/mvc

Share:
15,706

Related videos on Youtube

Dashang
Author by

Dashang

I am Web Developer

Updated on September 21, 2022

Comments

  • Dashang
    Dashang over 1 year

    I want to make a new project and I want to add a new page, using the Microsoft sample website as a starting point. The Microsoft sample website already has an About and a Contact page.

    How do I add a new page to the sample website using ASP.NET mvc4?

    • binarydreams
      binarydreams over 11 years
      Since you're clearly new to MVC, I strongly recommend you read through the official ASP.NET MVC guide as it will answer most of the "newbie" questions you might have.
  • James
    James over 5 years
    Thanks, that's the most concise explanation I've heard!