Create a project

Create a web API project

Follow the instructions below:

  1. Open your File Explorer

  2. Create a new folder named ContosoPizza in the location of your choice, and then open a terminal on that folder

  3. Use change directory command if required

  4. In the terminal window, copy and paste the following command:

    dotnet new webapi

    This command creates the files for a basic web API project that uses controllers, along with a C# project file named ContosoPizza.csproj that will return a list of weather forecasts.

    The command uses an ASP.NET Core project template, aliased as webapi, to scaffold a C#-based web API project. A ContosoPizza directory is created. This directory contains an ASP.NET Core project running on .NET. The project name matches the ContosoPizza directory name.

    You should now have access to these files:

    -| Controllers
    -| obj
    -| Properties
    -| appsettings.Development.json
    -| appsettings.json
    -| ContosoPizza.csproj
    -| Program.cs
    -| WeatherForecast.cs
  5. Examine the following files and directories:

    Name
    Description

    Controllers/

    Contains classes with public methods exposed as HTTP endpoints

    Program.cs

    Configures services and the app's HTTP request pipeline, and contains the app's managed entry point

    ContosoPizza.csproj

    Contains configuration metadata for the project

Last updated