ASP.NET Core Documentation

Getting Started

Create Your First ASP.NET Core Project

This guide will walk you through the essential steps to create a new ASP.NET Core web application project using the .NET CLI (Command Line Interface).

Prerequisites

Step-by-Step Project Creation

1

Open Your Terminal or Command Prompt

Navigate to the directory where you want to create your project. You can use the cd command to change directories.

cd path/to/your/projects/directory
2

Create the Project

Use the dotnet new command followed by the project template name. For a web application, we'll use the webapp template. The -o flag specifies the output directory (project name).

dotnet new webapp -o MyAspNetCoreApp

Replace MyAspNetCoreApp with your desired project name. This command will create a new folder with that name and generate the necessary project files inside.

3

Navigate into the Project Directory

Change your current directory to the newly created project folder.

cd MyAspNetCoreApp
4

Restore Dependencies

Run the following command to download and install any required NuGet packages and project dependencies.

dotnet restore
5

Run the Application

Execute the application using the dotnet run command.

dotnet run

The output will indicate that the application is listening on one or more URLs (typically https://localhost:7xxx and http://localhost:5xxx). Open your web browser and navigate to one of these URLs to see your running ASP.NET Core application.

Project Structure Overview

After creating the project, you'll find a structure similar to this (depending on the exact template used):

Next Steps

Congratulations! You've successfully created your first ASP.NET Core project. From here, you can start building your web application by adding new pages, controllers, models, and configuring services.