Reputation: 8807
What is the replacement of this code in .NET 3.0 with endpoint routing?
app.UseRouter(a => a.MapMiddlewareGet(
"middleware1",
b => b.UseMiddleware<Middleware1>()));
or should it be left like this:
app.UseRouter(a => a.MapMiddlewareGet(
"middleware1",
b => b.UseMiddleware<Middleware1>()));
app.UseEndpoints(a => a.MapControllers());
Upvotes: 5
Views: 868
Reputation: 1371
I think the following code helps you. I have tested and it is working.
app.UseEndpoints(endpoints =>
{
var newAppbuilder = endpoints.CreateApplicationBuilder();
newAppbuilder.UseMiddleware<Middleware1>();
endpoints.MapGet("middleware1", newAppbuilder.Build());
});
Upvotes: 1