解决 C# 中 Using 'UseMvcWithDefaultRoute' to configure MVC is not supported while using Endpoint Routin
1. 原因
版本更新导致
2. 解决
将
app.UseMvcWithDefaultRoute();
app.Run(async context =>
{
await context.Response.WriteAsync("Hello world");
});
改为
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute();
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Hello world");
});
});
参考网址:
[1]: https://q.cnblogs.com/q/115251/