See Routing to controller actions in ASP.NET Core
This doc page can be switched to 2.1. It shows attribute routing instructions.
But, methods like app.UseEndpoints(()=>), endpoints.MapControllers(); or app.MapControllers(); don't exist in my environment.
I've installed these packages:
Microsoft.AspNetCore.Hosting
Microsoft.AspNetCore.Http
Microsoft.AspNetCore.Mvc
Microsoft.AspNetCore.Routing
Microsoft.AspNetCore.Routing.Abstractions
What else should I install?
This is a documentation issue, the Endpoint routing applies to ASP.NET Core 3.0 and later, instead of Asp.net Core 2.1.
In Asp.net core 2.1 MVC application, you should use the
UseMvcmiddleware and theMapRoute()method, the startup.cs file like this:If you want to use the Endpoint routing, you could migrate the application from Asp.net core 2.1 to Asp.net core 3.1. Refer to this link and steps.
For the documentation issue, you can submit a feedback by click the button at the end of the document: