问题
I'm upgrading .NET Core 2.1 to .NET Core 3.0 and I saw here I have to use UseEndpoints. However, at some pages I've seen it with either MapControllerRoute, MapDefaultControllerRoute, or MapControllers.
I checked at the documentation and I saw that MapDefaultControllerRoute is basically the same as MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}"). But I don't understand the difference with MapControllers. What does this last function actually do? The documentation says: "Adds endpoints for controller actions to the IEndpointRouteBuilder without specifying any routes.", but I don't get it, sorry.
回答1:
MapControllers is used to map any attributes that may exist on the controllers, like, [Route], [HttpGet], etc.
来源:https://stackoverflow.com/questions/59107064/difference-between-mapcontrollerroute-mapdefaultcontrollerroute-and-mapco