C#C
C#3y ago
Ikinidae

❔ Controller routing with dynamic parameter

Hi all guys!
That's my first post so I don't know if I'm doing anything wrong, in case let me know!
I have an api project with a lot of api that are gonna be used for both a website (control panel) and a mobile app (for customers). My controllers are all like this:

[Route("api/v{version:apiVersion}/[controller]")]
[ApiVersion("1.0")]
[ApiController]
public class AgentController : ControllerBase
{
      // my api
}


that means that my url looks like this: https://localhost:5000/api/v1/Agent
What I need is to specify in the url if that api will be used in app or web, so that my url will look like this: https://localhost:5000/api/web/v1/Agent
That parameter has to be specified for every api just like [HttpGet("GetAgentById")].
I obviously searched on web but I haven't found anything 😦

Thanks a lot ❤️
Was this page helpful?