From the course: Learning ASP.NET Core: MVC, Razor Pages, Web APIs & Other Foundations

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Using middleware

Using middleware

- [Instructor] Middleware is software designed to handle and manipulate HTTP requests and responses. It's configured in what you can think of as a pipeline. With no middleware in place, HTTP requests are received by the server process and a response is sent to the client. When middleware is added to the pipeline, the request is processed by each successive piece of middleware on the way to the server, and in the reverse order when the response is sent back to the client. The middleware can manipulate the request and responses by doing things such as adding headers, enforcing authentication rules, and much more. There's lots of middleware built into ASP.NET Core that you can add to your app with a simple function call. You can also add your own custom middleware. I'll quickly show you an example of both. Most web apps need the ability to display some type of error page if an exception is thrown. ASP.NET Core includes a couple of pieces of middleware for this. One, for exceptions found…

Contents