Tuesday, April 14, 2020

.UseMvc in .NET Core with specific routes

This has this example and a bit more.

app.UseMvc(routes =>
{
   routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}");
});

 
 

Honestly, this is probably the .NET Core 2.0 way of doing things per this. In modern times (.NET 3.1.4) we have stuff like so instead:

app.UseEndpoints(endpoints =>
{
   endpoints.MapControllers();
});

No comments:

Post a Comment