0

No real code here, but looking for direction. I am using .net core web api. A potential requirement came up to use somewhat of a nested route for the api that is based on the user.

ie: https://blah.com/controller/YourNameHere/variable

Is that even possible?

I am used to this format in a controller:

[ApiController]
[Route("api/[controller]")]

I also believe you can specify static route like /api/[controller]/somethingstatic/id for example.

jps
  • 20,041
  • 15
  • 75
  • 79
raithedavion
  • 127
  • 1
  • 12

1 Answers1

0

You can specify routes on the ControllerMethods you use by specifying it with the HttpGet prefix: Eg:

[HttpGet("StageResult/{name}/something/{id}")]
public ActionResult<IEnumerable<TeamResultsDTO>> GetStageResults(string name, int id){ ... 

It is explained more clearly here: How to pass multiple parameters to a get method in ASP.NET Core

Arne
  • 16
  • 1