This behavior is not only present for RedirectToAction
, but also to links generated using Url.Action
.
While I cannot find out why it behaves like that, a workaround that I came up with is to continue generating links as is, but to include the next route segment as null:
So if we want to generate a URL with route values new { folder1 = "1st", folder2 = "2nd" }
, we also add folder3 = (string?)null
.
If we want to target the root, we pass new { folder1 = (string?)null }
.