Is there any way to add a parameter to the Controller Routing attribute?
something like:
[Route("controller/{id}/"]
public class Controller {
public Controller(string id) { /*..*/ }
[HttpGet]
public ActionResult Get() { /*..*/ }
}
The [FromRoute]
attribute on your controller method arguments should get you what you need.
Example
[Route("api/Test/{testId}")]
public class TestController: ControllerBase
{
[HttpGet]
[Route("echo")]
public void TestMethod([FromRoute]string testId)
{
return testId;
}
}
Also see this S.O. for more information.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments