Posts

Showing posts from September, 2019

Middleware in .Net Core

Image
I have read number of articles on middleware and watched some videos and now it’s time to explore it myself. Here, you will learn how to create and add your own custom middleware into the request pipeline of ASP.NET Core application. What Is Middleware? Middleware are small C# components that are assembled into an application pipeline to handle requests and responses. It defines steps that can progress through and each step leading into the next. It can be used for a wide variety of reasons from Authentication to Logging to Exception Handling etc Basic Custom middleware The custom middleware component is like any other .NET class with Invoke() method. However, in order to execute next middleware in a sequence, it should have RequestDelegate type parameter in the constructor. Visual studio includes template for adding middleware in our application. Let’s get started by adding one. For this right click on the project or folder wherever you want to add a middleware and add...