LearnAI ToolsCareerPractice BuildsPlayContact
Lesson 4818 min read

Setting Up an ASP.NET Core Project

Create your first ASP.NET Core web application and understand the generated project structure.

Creating a New Project

dotnet new webapi -o TaskApi
cd TaskApi

This scaffolds a minimal Web API project — a great starting point for the projects you'll build throughout this section.

Project Structure

File/FolderPurpose
Program.csApplication entry point and configuration
appsettings.jsonConfiguration values (connection strings, settings)
Controllers/API controllers (added as you build)
*.csprojProject file listing dependencies and settings

Understanding Program.cs

Program.cs
var builder = WebApplication.CreateBuilder(args);
// Add services to the container
builder.Services.AddControllers();
var app = builder.Build();
// Configure the HTTP request pipeline
app.UseHttpsRedirection();
app.MapControllers();
app.Run();

This single file both configures services (dependency injection, covered later) and builds the middleware pipeline that handles every incoming request.

Running the App

dotnet run
Example Output

Click Run to see what this code prints.

FAQs

`webapi` scaffolds a JSON API with no views; `mvc` adds Razor views and a full web app structure — you'll use both patterns in this section.

Summary

  • `dotnet new webapi` scaffolds a new ASP.NET Core Web API project.
  • Program.cs configures services and the request pipeline in one place.
  • `dotnet run` starts the app and prints the URL it's listening on.
Next Lesson →

MVC Architecture