In my ASP.NET Core Web API application, I have declared a route with multiple attributes like following
[HttpGet]
[Route("{tenantId?}/user/getsettings/{id?}")]
When I made a request from swagger, the server is returning 404 not found.
http://localhost:5163/api/1/user/getsettings/2
Is this possible with .NET Core?
Because your url actually not contains
api. You can call url by usinghttp://localhost:5163/1/user/getsettings/2. If you want to addapito your url you can add attribute to controller class by using[Route("api/v{version:apiVersion}/[controller]")].Tip: You can achive same config with only one
HttpGet("{tenantId?}/user/getsettings/{id?}")attribute.