The Run() method adds a RequestDelegate that is terminal to the pipeline. Any middleware components written after Run will not be processed as ASP.NET Core treats it as an end of the pipeline processing.

Copy the following code snippet in the beginning of the Configure method before the middleware written using Use():

    app.Run(async context => { 
      await context.Response.WriteAsync("Run() - a Terminal Middleware       <br/>"); 

Running the application, you will only see the Run() middleware executed with the rest of the middleware (1,2,3,4) not executed at all.

Some of the middleware do expose this method for treated as terminal middleware. It shouldn't be used in code to terminate the request processing.

Adopt the Use() method for request ...

Get Mastering ASP.NET Web API now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.