So I’m trying to use RedirectToAction()
to redirect to another action in the same controller. However, everything that I have tried has not worked. Ideally I want to be able to type the link /projects/assign/2
and be redirected to the /projects/create
page.
Examples of what I have tried:
[HttpGet]
public IActionResult Assign(int? id)
{
return View("Create", id);
}
And:
[HttpGet]
public IActionResult Assign(int? id)
{
return View("Create");
}
When I type /projects/assign/2
in the address bar, I receive an error that says:
"This page isn’t working. If the problem continues, contact the site
owner."
At this point, I’m not sure what I am doing wrong and how to make it work.
Any help/advice is greatly appreciated! Thank you!
2
Answers
Apply the following
Route
attributes:For more information see Routing in ASP.NET Core
just fix the action route