0
I am taking the MVC core course from developer.io, but in the course . net core 2.2 is used and I am using version 3.1. In creating a MVC project from scratch the route configuration code in . netcore 2.2’s Startup.Cs is:
app.UseMvc(routes =>
{
routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}");
//routes.MapRoute(
// name: "default",
// template: "{controller=Home}/{action=Index}/{id?}"
// )
});
And in . net core 3.1 is:
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Hello World!");
});
});
I tried to use the code of 2.2 in 3.1, but it’s not working because the code is already deprecated. I’d like to know the difference between the two codes, for example, why I use the endpoints.MapGet
in 3.1. What was the change they made between . net core 2.2 and 3.1 in the Startup.cs
?