I have the following situation
[Route("api/[controller]")]
[ApiController]
public class FooController: ControllerBase
{
[HttpGet("{id}", Name = "GetFoo")]
public ActionResult<FooBindModel> Get([FromRoute]Guid id)
{
// ...
}
}
[Route("api/[controller]")]
[ApiController]
public class Foo2Controller: ControllerBase
{
[HttpPost("/api/Foo2/Create")]
public ActionResult<GetFooBindModel> Create([FromBody]PostFooBindModel postBindModel)
{
//...
return CreatedAtRoute("GetFoo", new { id = getBindModel.Id }, getBindModel);
}
}
PS: getBindModel is an instance of type GetFooBindModel. And I am getting
InvalidOperationException: No route matches the supplied values.
I also tried changing the line
return CreatedAtRoute("GetFoo", new { id = getBindModel.Id }, getBindModel);
to
return CreatedAtRoute("api/Foo/GetFoo", new { id = getBindModel.Id }, getBindModel);
but still the same error.