Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 996
Matthew Layton Avatar asked Jun 23 '17 14:06

Matthew Layton


1 Answers

As @tmg mentioned, do the following:

Right click your web project -> Select Properties -> Select the Debug tab on the left -> Then edit the 'Launch Url' field to set your own default launch url.

Properties Pane of the project

like image 113
ctv Avatar answered Sep 19 '22 02:09

ctv