Chapter 5. Working with Middleware and Services

Sho Shimoda
2 min readJul 26, 2023

--

Welcome to Chapter 5, “Working with Middleware and Services.” This is a vital section of our journey through ASP.NET Core, where we’ll delve deep into the architectural heart of the framework. Understanding middleware and services is fundamental to mastering ASP.NET Core, as it governs how requests are processed and how components interact within your application.

We will begin with “5.1 Understanding the concept of middleware in ASP.NET Core.” Middleware in ASP.NET Core forms a chain of components that handle each HTTP request and response. Every bit of middleware has the chance to perform operations before and after the next middleware in the chain, thereby controlling the flow of the request.

After building a solid understanding of middleware, we will move to “5.2 Configuring and using built-in middleware.” ASP.NET Core provides various built-in middleware components that provide essential functionality, such as serving static files, handling errors, or even managing user authentication.

Once we’ve mastered the built-in middleware, we will proceed to “5.3 Creating custom middleware components.” There may be times when you need to perform custom operations on requests or responses, and ASP.NET Core allows for the creation of custom middleware for these scenarios.

Finally, we’ll cover “5.4 Working with dependency injection and services.” Dependency injection (DI) is a technique that helps maintain clean and loosely coupled code. ASP.NET Core comes with built-in support for DI, which you can use to provide services to your controllers, razor pages, and other components throughout your application.

By the end of this chapter, you will have a deep understanding of how ASP.NET Core processes requests and how to customize this process to your application’s specific needs. It’s time to take our ASP.NET Core skills to a new level as we plunge into the fascinating world of middleware and services.

Next: 5.1 Understanding the concept of middleware in ASP.NET Core

--

--

Sho Shimoda

CEO/CTO of {RECEIPT}ROLLER. We offer easy digital receipt solutions for all POS and e-commerce, eliminating paper waste.