liveBook · Manning

Chapter 3: Your first application

What you will learn in chapter 3 of ASP.NET Core in Action, 3e

This chapter introduces the workflow of creating, running, inspecting, and lightly extending a template-based ASP.NET Core application.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This chapter introduces the workflow of creating, running, inspecting, and lightly extending a template-based ASP.NET Core application.

Key terms: template, ASP.NET Core application, dependencies, compile, run, Hello World, project layout, Program.cs, static files, API

3.1 A brief overview of an ASP.NET Core application

This section outlines how an ASP.NET Core application turns an incoming HTTP request into a response through Kestrel, HttpContext, middleware, and an endpoint.

Key terms: reverse proxy, Kestrel, HttpContext, middleware pipeline, endpoint middleware, MVC, request-specific services, HTTP request

3.2 Creating your first ASP.NET Core application

This section introduces the first minimal API application, the basic local application workflow, and the main ASP.NET Core template types.

Key terms: minimal API, HTTP API, Hello World!, Generate, Restore, Build, Run, NuGet, template, Minimal API applications

3.2.1 Using a template to get started

This section creates a first minimal API project from the ASP.NET Core Empty template using Visual Studio or the .NET CLI and clarifies the resulting project and solution structure.

Key terms: template, minimal API application, Visual Studio, .NET CLI, ASP.NET Core Empty, C#, NET 7.0, Configure for HTTPS, Enable Docker, Do not use top-level statements

3.2.2 Building the application

This section explains how the .NET CLI restores NuGet dependencies and builds an ASP.NET Core project into runnable binaries.

Key terms: NuGet package manager, NuGet dependencies, dotnet restore, .csproj, PackageReference, dotnet build, compile, output binaries, dotnet run, .NET CLI

3.3 Running the web application

This section shows how to run the new ASP.NET Core app from Visual Studio or the .NET CLI and verify its Hello World response.

Key terms: Visual Studio, F5, dotnet run, .NET CLI, URL, endpoint, path /, Hello World!, plain-text response, development certificate

3.4 Understanding the project layout

This section orients you to the files, folders, and Visual Studio nodes in a newly created ASP.NET Core web application.

Key terms: solution folder, solution (.sln) file, project folder, Solution Explorer, .csproj, WebApplication1.csproj, NuGet packages, Dependencies, Properties, launchSettings.json

3.5 The .csproj project file: Declaring your dependencies

This section explains how the .csproj project file tells .NET how to build an application and how to add reusable NuGet package dependencies.

Key terms: .csproj, project file, TargetFramework, NuGet packages, .NET CLI, Sdk, Project element, implicit file includes, PackageReference, packages.config

3.6 Program.cs file: Defining your application

This section explains how Program.cs uses top-level statements, WebApplicationBuilder, WebApplication, endpoints, and Run() to configure and start a minimal ASP.NET Core application.

Key terms: top-level statements, Main, args, implicit using statements, WebApplicationBuilder, WebApplication, CreateBuilder, Build, builder pattern, configuration

3.7 Adding functionality to your application

This section introduces the standard Program.cs setup sequence and previews how services, middleware, and endpoints add behavior to an ASP.NET Core application.

Key terms: WebApplicationBuilder, WebApplication, Build(), middleware, endpoints, Run(), HttpLoggingMiddleware, Development environment, endpoint, /person

3.7.1 Adding and configuring services

This section explains why ASP.NET Core applications register modular framework and custom services with the WebApplicationBuilder before building the app, including HTTP logging and logging configuration.

Key terms: service, single-responsibility principle, SRP, dependency injection, Inversion of Control, IoC, WebApplicationBuilder, Services, IServiceCollection, IoC container

3.7.2 Defining how requests are handled with middleware and endpoints

This section explains how a WebApplication uses ordered middleware and mapped endpoints to select, execute, and return responses for HTTP requests.

Key terms: WebApplication, middleware pipeline, endpoints, Run(), middleware, Use* extension methods, UseHttpLogging(), WebApplication.Environment, IWebHostEnvironment, EnvironmentName

3.8 Summary

This summary recaps how an ASP.NET Core project declares dependencies and how Program.cs builds, configures, and runs a request-handling application.

Where this is used later

Concepts explained in this chapter

← Chapter 2: Understanding ASP.NET Core Chapter 4: Handling requests with the middleware pipeline →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.