我不能在 .NET Core 3.1 中使用像在 .NET Core 2.2 中那样的简单路由。
.NET Core 3.1 中路由的最后更改是什么?
最佳答案
在 .NET 3 中你应该使用 端点 而不是 路由
app.UseStaticFiles();
app.UseRouting();
//other middleware
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapRazorPages();
endpoints.MapHub<MyChatHub>();
endpoints.MapGrpcService<MyCalculatorService>();
endpoints.MapControllerRoute(name: "default", pattern: "{controller=Home}/{action=Index}/{id?}");
});
关于c# - 如何在 ASP.NET Core 3.1 MVC 中进行自定义路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59223635/