0

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?

2
  • 1
    try without the api in the url Commented Apr 21, 2022 at 19:20
  • You may read this section for more details Commented Apr 22, 2022 at 1:48

1 Answer 1

1

Because your url actually not contains api. You can call url by using http://localhost:5163/1/user/getsettings/2. If you want to add api to 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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.