Run()

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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.