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());
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());
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With