© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
5 replies
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
}
[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 ❤️
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Controller Routing errors
C#CC# / help
2y ago
✅ Controller routing in 2023
C#CC# / help
3y ago
✅ Pass status as parameter in controller
C#CC# / help
3y ago
Blazor routing with multiple parameters [Answered]
C#CC# / help
4y ago