Chapter 1: Getting started with ASP.NET Core
This chapter introduces what ASP.NET Core is, why it may suit web application development, the role of .NET 7, and its basic request-processing mechanics.
After this chapter you will be able to
- ASP.NET Core identity. Describe ASP.NET Core as an open-source, cross-platform application framework for building dynamic web applications quickly, and state that it runs on .NET 7.
- Framework and business logic layers. Explain that ASP.NET Core supplies structure and helper code to handle client requests, then invokes application handlers that call the application's business logic; describe business logic as the core of the app that typically does not directly depend on ASP.NET Core.
- Supported application paradigms. Describe the types of applications ASP.NET Core can build, including HTTP APIs, gRPC APIs, server-rendered applications, and browser-based or stateful single-page applications. Distinguish the main paradigms by the kind of application or communication style each supports.
- Shared foundations and selection. Explain that all ASP.NET Core paradigms use common building blocks, such as configuration and logging, with additional functionality layered on top. Describe why paradigm choice depends on requirements such as APIs, existing integrations, client browsers and environments, scalability, and uptime, and why an application can combine paradigms.
- Recommendation for new .NET apps. State Microsoft's recommendation for new .NET web applications and distinguish the future of ASP.NET Core and .NET 7 or newer from that of the older ASP.NET framework and .NET Framework.
- Cross-platform platform advantages. Explain that the same ASP.NET Core application can be developed and run on Windows, macOS, and Linux, and describe practical opportunities this creates for deployment and development.
- Request-to-page processing overview. Describe the overall path this section will examine: a user requests a URL and the browser ultimately displays a page. State that the explanation first covers ordinary HTTP web-server requests and then shows how ASP.NET Core extends that process to create dynamic web pages.
- Browser-to-server request journey. Trace what happens after a user enters a URL: the hostname is resolved through DNS to an IP address, and the browser sends an HTTP request across the internet to the server hosting the web app. Describe that routers may relay the request, but the application processes it only when it reaches the server associated with the hostname.
- HTTP request-response message structure. Describe HTTP as a stateless request-response protocol in which a client sends a request and a server returns a response. State that a request has a verb and path, may have headers and a body, while a response has a status code and can also have headers and a body.
- ASP.NET Core request lifecycle. Trace the server-side path of an HTTP request through an ASP.NET Core application, from the browser sending it to the browser receiving the response. Include that the user still experiences ordinary HTTP request-and-response communication while the ASP.NET Core-specific work occurs on the server.
- Kestrel and HttpContext roles. Describe Kestrel's role as the default built-in web server and explain how it turns a raw network request into an HttpContext that the application uses. Explain that, after application processing, Kestrel converts the response representation back into a raw HTTP response for the network.
- Application development paths. Describe the two main application styles the book teaches: HTTP APIs built with minimal APIs and page-based applications built with Razor Pages.
- Framework concepts and features. State that the book covers core request and application features including routing, model binding, validation, Razor syntax, Tag Helpers, dependency injection, configuration, logging, and security best practices.
Section by section
Introduction
This chapter introduces what ASP.NET Core is, why it may suit web application development, the role of .NET 7, and its basic request-processing mechanics.
- Chapter learning roadmap: Describe the chapter's promised overview: what ASP.NET Core is, what can be built with it, why to choose it, the role of .NET 7, and the basic mechanics of how it works.
Why it matters: This roadmap frames the questions the rest of the chapter answers before you invest in learning the framework.
Key terms: ASP.NET Core, .NET 7, web applications
1.1 What is ASP.NET Core?
Introduces ASP.NET Core as a cross-platform web application framework and positions it around an application's independent business logic.
- ASP.NET Core identity: Describe ASP.NET Core as an open-source, cross-platform application framework for building dynamic web applications quickly, and state that it runs on .NET 7.
Why it matters: This establishes what ASP.NET Core is and the runtime platform on which its applications run. - Supported application types: State that ASP.NET Core can build server-rendered web applications, backend server applications, and HTTP APIs consumable by mobile applications.
Why it matters: The range of application types shows that ASP.NET Core is not limited to generating web pages. - Framework and business logic layers: Explain that ASP.NET Core supplies structure and helper code to handle client requests, then invokes application handlers that call the application's business logic; describe business logic as the core of the app that typically does not directly depend on ASP.NET Core.
Why it matters: Keeping business logic separate from the framework makes the application's core less tied to web-framework details.
Key terms: ASP.NET Core, .NET 7, cross-platform, open-source, application framework, dynamic web applications, server-rendered web applications, backend server applications, HTTP APIs, mobile applications
1.2 What types of applications can you build?
This section surveys the application paradigms ASP.NET Core supports and explains that they share foundations, can be combined, and must be chosen according to application needs.
- Supported application paradigms: Describe the types of applications ASP.NET Core can build, including HTTP APIs, gRPC APIs, server-rendered applications, and browser-based or stateful single-page applications. Distinguish the main paradigms by the kind of application or communication style each supports.
Why it matters: Knowing the available paradigms lets you recognize which ASP.NET Core approach fits the kind of application you need to build. - Shared foundations and selection: Explain that all ASP.NET Core paradigms use common building blocks, such as configuration and logging, with additional functionality layered on top. Describe why paradigm choice depends on requirements such as APIs, existing integrations, client browsers and environments, scalability, and uptime, and why an application can combine paradigms.
Why it matters: The shared foundation means you can select or mix application styles based on practical requirements instead of treating each paradigm as an isolated platform.
Key terms: Minimal APIs, Web APIs, gRPC APIs, Razor Pages, MVC controllers, Blazor WebAssembly, building blocks, configuration, logging, paradigms
1.3 Choosing ASP.NET Core
This section explains why ASP.NET Core is the recommended choice for new .NET web development, emphasizing its modern cross-platform advantages and continuity with older ASP.NET experience.
- Recommendation for new .NET apps: State Microsoft's recommendation for new .NET web applications and distinguish the future of ASP.NET Core and .NET 7 or newer from that of the older ASP.NET framework and .NET Framework.
Why it matters: This helps you choose a supported platform for new work instead of confusing continued support with ongoing product development. - Cross-platform platform advantages: Explain that the same ASP.NET Core application can be developed and run on Windows, macOS, and Linux, and describe practical opportunities this creates for deployment and development.
Why it matters: Cross-platform support lets teams choose their operating systems, cloud hosts, containers, and development machines more freely. - Modern framework selling points: Describe the main reasons ASP.NET Core is presented as an attractive modern web framework, including performance, open-source and modular design, familiar patterns, broad application paradigms, and a simplified hosting model.
Why it matters: These characteristics explain why ASP.NET Core can be a compelling option even when compared with other cross-platform frameworks. - Continuity with classic ASP.NET: Explain why moving from the previous ASP.NET framework to ASP.NET Core does not discard existing knowledge, including the continued relevance of shared concepts and IIS hosting.
Why it matters: This reassures established .NET developers that adopting ASP.NET Core is an evolution rather than a complete restart.
Key terms: ASP.NET Core, .NET 7, .NET Framework, ASP.NET framework, bug and security fixes, feature updates, cross-platform, Windows, macOS, Linux
1.4 How does ASP.NET Core work?
Introduces the upcoming explanation of how a browser URL request becomes a displayed page, first through HTTP and then through ASP.NET Core's dynamic processing.
- Request-to-page processing overview: Describe the overall path this section will examine: a user requests a URL and the browser ultimately displays a page. State that the explanation first covers ordinary HTTP web-server requests and then shows how ASP.NET Core extends that process to create dynamic web pages.
Why it matters: This overview gives you the mental path for understanding how an ASP.NET Core application responds to a browser request. - Section progression: State that the section's explanation proceeds from how HTTP works for any web server to how ASP.NET Core builds on that process. Identify the corresponding follow-up parts as the HTTP request discussion and the ASP.NET Core request-processing discussion.
Why it matters: Recognizing this order helps you separate universal web concepts from ASP.NET Core's added behavior.
Key terms: HTTP request, web server, URL, dynamic web pages, ASP.NET Core, HTTP web request
1.4.1 How does an HTTP web request work?
This section traces how a browser uses HTTP to request a resource from a server and then fetches the additional files needed to render a web page.
- Browser-to-server request journey: Trace what happens after a user enters a URL: the hostname is resolved through DNS to an IP address, and the browser sends an HTTP request across the internet to the server hosting the web app. Describe that routers may relay the request, but the application processes it only when it reaches the server associated with the hostname.
Why it matters: This journey explains how a browser request reaches the ASP.NET Core application that will generate a response. - HTTP request-response message structure: Describe HTTP as a stateless request-response protocol in which a client sends a request and a server returns a response. State that a request has a verb and path, may have headers and a body, while a response has a status code and can also have headers and a body.
Why it matters: Understanding the parts of HTTP messages is the foundation for understanding how ASP.NET Core handles requests and creates responses. - Page resource request cycle: Explain that the server can return HTML or another resource in an HTTP response, and that the browser begins displaying received content. Describe why the browser makes further HTTP requests for resources referenced by HTML, such as CSS, JavaScript, and images, in order to render the complete page.
Why it matters: A visible web page is commonly the result of many separate HTTP requests, not one request for a single complete file.
Key terms: URL, hostname, path, Domain Name Service (DNS), IP address, HTTP request, Hypertext Transfer Protocol (HTTP), stateless, request-response protocol, client
1.4.2 How does ASP.NET Core process a request?
This section traces how an ASP.NET Core application receives an HTTP request through Kestrel, processes it using HttpContext, and returns an HTTP response.
- ASP.NET Core request lifecycle: Trace the server-side path of an HTTP request through an ASP.NET Core application, from the browser sending it to the browser receiving the response. Include that the user still experiences ordinary HTTP request-and-response communication while the ASP.NET Core-specific work occurs on the server.
Why it matters: This lifecycle gives you the big-picture path that later ASP.NET Core components participate in. - Kestrel and HttpContext roles: Describe Kestrel's role as the default built-in web server and explain how it turns a raw network request into an HttpContext that the application uses. Explain that, after application processing, Kestrel converts the response representation back into a raw HTTP response for the network.
Why it matters: Kestrel and HttpContext are the boundary between raw HTTP traffic and the information ASP.NET Core application code works with. - Application response generation: Explain that application code uses details in HttpContext to choose and generate an appropriate response, such as HTML, an access-denied message, or an action like sending an email, according to the application's requirements.
Why it matters: A response is not limited to rendering a web page; it is the result of application-specific handling of the request.
Key terms: HTTP request, HTTP response, ASP.NET Core application, server-side, Kestrel, web server, HttpContext, raw request, raw HTTP response, response
1.5 What you’ll learn in this book
This section previews the book’s ASP.NET Core topics, examples, tooling expectations, and cross-platform learning environment.
- Application development paths: Describe the two main application styles the book teaches: HTTP APIs built with minimal APIs and page-based applications built with Razor Pages.
Why it matters: This helps you understand the major kinds of ASP.NET Core applications the book will develop. - Framework concepts and features: State that the book covers core request and application features including routing, model binding, validation, Razor syntax, Tag Helpers, dependency injection, configuration, logging, and security best practices.
Why it matters: These features are the building blocks used as ASP.NET Core applications become more capable and complex. - Examples and development environment: Describe that examples are generally small and self-contained to focus on one feature, and that readers can use their preferred editor or IDE on Windows, Linux, or Mac with the .NET 7 SDK installed.
Why it matters: Knowing the examples are focused and the tools are cross-platform helps you follow the book in your own development environment.
Key terms: HTTP API, minimal APIs, Razor Pages, model binding, validation, routing, Razor syntax, Tag Helpers, dependency injection, Visual Studio
1.6 Summary
This summary recaps ASP.NET Core’s platform, application styles, recommendation for new development, and role in handling HTTP requests.
Where this is used later
- Why ASP.NET Core was created (chapter 2) · Explains why ASP.NET Core was created and its cross-platform design.
- A brief overview of an ASP.NET Core application (chapter 3) · Uses ASP.NET Core as the framework underlying an application project.
- What is an HTTP API, and when should you use one? (chapter 5) · Introduces HTTP APIs as one application style.
- Your first Razor Pages application (chapter 13) · Builds a server-rendered website with Razor Pages.
- Defining how requests are handled with middleware and endpoints (chapter 3) · Defines request handling through middleware and endpoints.
- Creating loosely coupled code (chapter 8) · Uses separation and loose coupling as motivations for dependency injection.
- Understanding the many paradigms of ASP.NET Core (chapter 2) · This section examines the multiple ASP.NET Core paradigms in more detail.
- Razor Pages vs. MVC in ASP.NET Core (chapter 19) · This section compares Razor Pages and MVC controllers.
Concepts explained in this chapter
- ASP.NET CoreASP.NET Core is Microsoft's cross-platform, open-source web framework for building web applications and services on .NET.
- api callAn HTTP request is a client-to-server message specifying an operation on a resource and optionally carrying headers and a body.
- serverA web server is software or a host system that receives HTTP requests and returns HTTP responses containing web resources.
- .NET.NET 5+ is the unified generation of the .NET platform comprising .NET 5, .NET 6, and later releases.
- web applicationA web application is software that provides functionality to users through web technologies and a browser or other web client.
- Razor PagesA Razor Page is an independently addressable ASP.NET Core page endpoint typically composed of a .cshtml view file and an associated PageModel class.
- minimal APIA minimal API endpoint is an addressable operation in a minimal API application that handles a request with minimal surrounding framework structure.
- web serviceAn HTTP API application exposes application functionality through endpoints that communicate using the HTTP protocol.
- domain name systemDNS is the hierarchical naming system that resolves hostnames to IP addresses and other network records.
- uriA URL is a standardized identifier that specifies the location of a resource and may include a hostname and path.
- url pathAn HTTP path identifies the resource or resource location targeted by an HTTP request.
- ASP.NETASP.NET is Microsoft's legacy web application framework for the .NET ecosystem, preceding ASP.NET Core.
- gRPCgRPC is a high-performance, language-independent remote procedure call framework for service-to-service communication.
- Blazor ServerBlazor Server is a Blazor hosting model in which UI rendering and event handling execute on the server while updates are sent to the browser.
- contractA web API is an HTTP-accessible application interface that exposes operations or data to clients.
- controllerA web API controller is an ASP.NET Core controller that handles HTTP API requests through action methods and produces machine-readable responses.
- HttpContextHttpContext is the ASP.NET Core object that represents the information and state associated with a single HTTP request and its response.
- KestrelKestrel is the cross-platform web server included with ASP.NET Core for receiving and sending HTTP traffic.
- Razor syntaxA Razor view is a server-rendered template that combines markup with embedded C# expressions and accesses data supplied by an application component.
- Tag HelpersTag Helpers are ASP.NET Core components that add server-side processing behavior to HTML-like elements in Razor files.
- configurationConfiguration is the set of external settings and secrets that control an application's runtime behavior.
- dependency injectionDependency injection is a design pattern in which an object receives its dependencies from an external provider rather than creating them itself.
- model bindingA model binder is the framework component that locates request values, converts them to appropriate types, and assigns them to bound objects or parameters.
- monitoringLogging is the recording of diagnostic or operational messages generated by an application.
- routingRouting is the mechanism that maps incoming requests to application endpoints or handlers.
- validationValidation is the application framework process that checks model data against rules to determine whether it is acceptable.
- business logicBusiness logic is the application behavior that implements domain rules, decisions, and processes independently of presentation or infrastructure concerns.
- HTTP methodAn HTTP verb is the method token in an HTTP request that indicates the intended operation.
- HTTP response codeAn HTTP status code is a three-digit code in an HTTP response that indicates the result of processing the corresponding request.
- payloadA JWT payload is the token section that contains its claims and other encoded data.
- .NET Framework.NET Framework is Microsoft's legacy Windows-focused platform and runtime for building .NET applications.
- hosting modelA hosting model is the architecture and configuration that determines how an application is started, managed, and exposed by its host environment.
- Model–view–controllerModel-View-Controller is an application architecture pattern that separates domain data, presentation, and request-handling control logic.
- logging moduleA logging library provides APIs for recording and routing diagnostic and operational messages from an application.
- server-side renderingServer-side rendering is the process of generating HTML on the server before sending it to a client.
- single-page applicationA single-page application is a web application that updates its user interface dynamically without full-page navigation for most interactions.
- RESTA RESTful API is a web API designed around REST constraints and resource-oriented HTTP interactions.
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.
