.net core 3.0 实现MVC的方式是

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

使用app.UseMvc()会提示一下信息,如果一定想这么实现的话可以在 Startup.cs的 ConfigureServices方法中添加  services.AddMvc(options => options.EnableEndpointRouting = false);解决

 

Using ‘UseMvc’ to configure MVC is not supported while using Endpoint Routing.

    public void ConfigureServices(IServiceCollection services)
        {
            services.AddRazorPages();
            services.AddSignalR();
            services.AddMvc(options => options.EnableEndpointRouting = false);
        }

 


本文转载:CSDN博客