- Use() method: Used to create a simple middleware which can be "chained" to other functions over the pipeline. Takes two arguments: RequestDelegate and HttpContext. It is chained by calling the next() method on the RequestDelegate.
- Run() method: "short-circuit" the request pipeline for a given condition. Takes a single argument of HttpContext and can be used to write on the Response.
app.Use(async (context, next) =>
{
// Do something here
// Call the next middleware
await next.Invoke();
});
app.Run(async context =>
{
// short-circuit the request
// write a response back
await context.Response.WriteAsync("Hello from Run");
});