Difference between `MapControllerRoute`, `MapDefaultControllerRoute`, and `MapControllers`?

MapControllers is used to map any attributes that may exist on the controllers, like, [Route], [HttpGet], etc.


MapControllerRoute

Uses conventional routing (most often used in an MVC application), and sets up the URL route pattern. So you will have seen this in tutorials/documentation with something like this:

endpoints.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");

You could set this to whatever you wanted (within reason) and your routes would follow this pattern. The above pattern is basically {{root_url}}/{{name_of_controller}}/{{name_of_action}}/{{optional_id}} where, if controller and action are not supplied, it defaults to home/index.

MapDefaultControllerRoute This is the above, but it shorthands the configuration of the default pattern that I displayed above.

MapControllers This doesn't make any assumptions about routing and will rely on the user doing attribute routing (most commonly used in WebAPI controllers) to get requests to the right place.

N.B. It's entirely possible to use MapControllerRoute (and by proxy MapDefaultControllerRoute) along side attribute routing as well. If the user does not supply attributes, it will use the defined default pattern.