Create new pages asp.net mvc

Here are the steps to create new pages in an ASP.NET MVC application:

Method 1: Using the "Add" menu

  1. Open your ASP.NET MVC project in Visual Studio.
  2. Right-click on the project in the Solution Explorer and select "Add" > "New Item...".
  3. In the "Add New Item" dialog box, select "ASP.NET MVC View Page" under the "Web" section.
  4. Name your new page (e.g., "About") and select a location to save it (e.g., "Views/Home").
  5. Click "Add" to create the new page.

Method 2: Using the "View" folder

  1. Open your ASP.NET MVC project in Visual Studio.
  2. Navigate to the "Views" folder in the Solution Explorer.
  3. Right-click on the folder and select "Add" > "New Folder" to create a new subfolder (e.g., "Home").
  4. Right-click on the new subfolder and select "Add" > "New Item...".
  5. In the "Add New Item" dialog box, select "ASP.NET MVC View Page" under the "Web" section.
  6. Name your new page (e.g., "About") and click "Add" to create the new page.

Creating a new page with a controller

If you want to create a new page with a corresponding controller, you can follow these steps:

  1. Create a new view page using one of the methods above.
  2. In the "Views" folder, navigate to the subfolder that corresponds to the controller you want to create (e.g., "Home").
  3. Right-click on the subfolder and select "Add" > "New Item...".
  4. In the "Add New Item" dialog box, select "Controller" under the "Web" section.
  5. Name your new controller (e.g., "HomeController") and click "Add" to create the new controller.
  6. In the new controller, add an action method that corresponds to the new view page (e.g., "About").
  7. In the action method, return the new view page using the View() method (e.g., return View();).

For example, if you created a new view page called "About.cshtml" in the "Views/Home" folder, you would create a new controller called "HomeController.cs" in the "Controllers" folder with an action method like this:

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

This will render the "About.cshtml" view page when the user navigates to the /Home/About URL.