liveBook · Manning

ASP.NET Core

As explained in ASP.NET Core in Action, 3e

ASP.NET Core is Microsoft's cross-platform, open-source web framework for building web applications and services on .NET.

ASP.NET Core is Microsoft’s cross-platform, open-source web framework for building dynamic applications and services on .NET. It supplies common web infrastructure so you can focus on application behavior instead of writing networking and framework code from scratch. section 1.1 section 2.1

Framework code handles requests and calls handlers you write, such as Razor Pages or Web API controllers. Those handlers call application business logic, which typically does not depend directly on ASP.NET Core. The business logic can also interact with databases or remote APIs. section 1.1

Figure 1.1 A typical ASP.NET Core application consists of several layers. The ASP.NET Core framework code handles requests from a client, dealing with the complex networking code. Then the framework calls in to handlers (Razor Pages and Web API controllers, for example) that you write using primitives provided by the framework. Finally, these handlers call in to your application’s domain logic—typically, C# classes and objects without any dependencies that are specific to ASP.NET Core.
CH01_F01_Lock3

See how request handling, application handlers, and business logic fit together. section 1.1

Choose an application style based on what your users and other systems need:

  • Use minimal APIs for simple HTTP APIs, or Web APIs when you want more structure and features. section 1.2
  • Use Razor Pages for page-based server-rendered applications, or MVC controllers for server-rendered applications without the page-based model. section 1.2
  • Use gRPC for binary server-to-server APIs. Blazor WebAssembly runs a single-page application in the browser; Blazor Server sends UI events and updates over WebSockets. section 1.2

These styles share building blocks such as configuration and logging, and you can combine them in one application. Consider API requirements, existing systems, users’ environments, scalability, and uptime when choosing. section 1.2

A request normally reaches the application’s web server, Kestrel by default. The server turns the incoming request into an HttpContext, which holds information for that request and its response. The middleware pipeline processes the request; an endpoint can generate a response, which passes back through the pipeline and server to the client. A reverse proxy may sit in front of the application. section 1.4.2 section 3.1

Figure 3.1 An overview of an ASP.NET Core application. The ASP.NET Core application receives an incoming HTTP request from the browser. Every request passes to the middleware pipeline, which potentially modifies it and then passes it to the endpoint middleware at the end of the pipeline to generate a response. The response passes back through the middleware to the server and finally out to the browser.
CH03_F01_Lock3

Follow a request through the server and middleware pipeline and back to the browser. section 3.1

A first minimal API

Start with an application template that returns “Hello World!” from an HTTP API. The local workflow is to generate the project, restore its NuGet dependencies, build it, and run it. With the .NET CLI, the corresponding commands are dotnet new, dotnet restore, dotnet build, and dotnet run. Visual Studio templates offer another way to start. section 3.2 section 27.1.1

A successful build produces application artifacts, but deployment requires publishing the app to include additional files. Cross-platform development also has a practical caveat: Windows-specific APIs remain available only on Windows, even when enabled through the Windows Compatibility Pack. section 27.1.1 section 2.4.2

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains application layers and request processing from Kestrel through middleware, then introduces generating, restoring, building, and running an application.
Examples
Uses a company-information web app to illustrate request handling and a Hello World minimal API to introduce the development workflow.
What it assumes
Assumes familiarity with C# or a similar object-oriented language and benefits from basic HTML and JavaScript familiarity.
What you can do after
Apply it via ASP.NET Core to build minimal HTTP APIs and Razor Pages applications, using routing, validation, configuration, and security practices.
How it connects
Connects ASP.NET Core with .NET, HTTP, middleware, Razor Pages, minimal APIs, dependency injection, configuration, and logging.

Also explained in

Compare how 3 books explain ASP.NET Core →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.