So I've been studying the documentation of.net Core Middleware and it mentions there are three types of request delegates: Run, Use and Map. I use app.MapGet() to handle a few specific routes and I have a few app.Use() to filter some incoming requests for various purposes. And I have an app.Run() in my code also. And I wonder why it is actually needed.
If I remove it, the site won't work with a "HTTP Error 500.30 - ASP.NET Core app failed to start" message so I seem to need it.
But then I see this code example:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.Run(async context =>
{
await context.Response.WriteAsync("Hello world!");
});
app.Run();
And I can't help but wonder why this has an extra app.Run() in it, with parameters. I'm trying to understand why I would use this second app.Run() in my code.
So, what is the use case for having multiple app.Run() commands in my code?