Now is the right time to create simple middleware of our own and plug it into the pipeline, so that all this theory that we have gone through ends with a practical example.
We can write either inline middleware or a neatly written class which can be configured at the startup. We will write both:
public void Configure(IApplicationBuilder app) { app.Run(async context => { await context.Response.WriteAsync(".NET Core 2.0 By Example"); }); }
This is the simplest middleware that one can write. This is the Run middleware and short-circuits the pipeline after execution, and just sends a response with the message ".NET Core 2.0 By Example". It has been plugged with this code into the Configure method ...