aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

What's the point of the “api” path segment in newly created ..net core API project default template

Open leealexander opened this issue 7 years ago • 3 comments

Is your feature request related to a problem? Please describe.

When I create a new API only .Net Core project the default route is [Route("api/[controller]")] resulting in something like http://localhost:1234/api/customers. When it comes time to deploy e.g api.wonderfulweb.com, then it looks like this api.wonderfulweb.com/api/customers.

Describe the solution you'd like

I can only see the point of having the api path segment if you're sharing the same project with the UI controllers which I'm clearly not since I've selected an"API" project. It seems to me the default for a single API project is wrong and it should be [Route("[controller]")] or [Route("v1/[controller]")]?

Describe alternatives you've considered

Of course it's pretty straight forward to change it, but some devs will follow this pattern like lemmings unless they are handed the solution on a plate.

Additional context

N/A

leealexander avatar Feb 05 '19 20:02 leealexander

@glennc @JamesNK Do we plan to remove the "api" path segment from our Web API templates?

danroth27 avatar Feb 06 '19 14:02 danroth27

Yes, it's been something we intended to remove for a while but we've never done.

glennc avatar Feb 11 '19 22:02 glennc

This is done in 3.0. The WeatherForecastController is in /weatherforecast.

pranavkm avatar Oct 15 '19 21:10 pranavkm