ASP.NET Core WebAPI default route not working
问题 I've followed several examples suggesting that to set my default route in an ASP.NET Core WebAPI project, I need to replace app.UseMvc(); with app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action}", defaults: new { controller = "Traders", action = "Get" }); }); But when I run it defaults to localhost:54321/api/values and it should default to localhost:54321/Traders What's wrong? 回答1: As @tmg mentioned, do the following: Right click your web project ->