I am trying to convert a .NET Core 3.1 project to .NET 7.
When I use this in my Program.cs
class:
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
It gives me this message:
Suggest using top level route registrations UseEndpoints
Then, I clicked on Show potential fixes
in Visual Studio and it suggests this:
app.UseEndpoints(endpoints =>
{
_ = endpoints.MapRazorPages();
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
Which looks the same to me.
In .NET 7, what should I do if I need to use RazorPages()?
Thanks!
UseEndpoints
and I can just changeendpoints.MapControllerRoute
toapp.MapControllerRoute
? Thanks! – Pyosis