While having this route mapping:
app.MapControllerRoute(
"ViewAct",
"Cont1/Act1/{id}/{title?}",
new { controller = "Cont1", action = "Act", id = "" });
When calling RedirectToAction from a different controller action, the id parameter will arrive as zero 0;
So when calling redirect from here:
public ActionResult Act2(long id, long nid) // id = 123
{
return RedirectToAction("Act1", new { id = id, title = "" });
}
public async Task<IActionResult> Act1(long id, string title) // id == 0
id will be 0.
Redirecting from Act1 to Act1 works (id gets value), also if I delete the MapControllerRoute on top, it will also work.
Remove the
idvalue from the defaults parameter:Providing the valid default value (which can be parsed into
long) foridalso works: