Hi folks I have a problem with using CreateAtAction in asp .net 8 api when I need to use it in my post or put request to go to a get request I have tried to make too many things to solve it by adding
[ActionName(nameof([Your Action Name]))]
or to add a Name to the HttpGet Notation
[HttpGet("{variable}" , Name =nameof([Your Action Name]))]
or like this
[HttpGet("{variable}" , Name ="[Unique name]")]
also i make the two together like this
[Route("[controller]")]
[ApiController]
public class AreaController : ControllerBase
{
// [HttpGet("{variable}" , Name =nameof([Your Action Name]))]
//or
// [HttpGet("{variable}" , Name ="[Unique name]")]
//and
// [ActionName(nameof([Your Action Name]))]
public async Task<ActionResult<YourClass>> GetSomething(int variable)
{
}
[HttpPost]
public async Task<ActionResult<YourClass>> PostSomething(YourClass pass)
{
// return CreatedAtAction(nameof([Your Action Name]), new { variable = pass.Id });
//or
// return CreatedAtAction("[Unique name]", new { variable = pass.Id });
//or
// return CreatedAtAction(nameof([Your Action Name]), new { variable = pass.Id },pass);
//or
// return CreatedAtAction("[Unique name]", new { variable = pass.Id },pass);
}
}
note : this when I pass this ([Wherever], new { variable = pass.Id },pass) it return the pass object not going to the Get request
Otherwise the problem still occurs
I tried those techniques
No route matches the supplied values
ASP.NET Core: CreatedAtAction - No route matches the supplied values


