79309559

Date: 2024-12-26 13:13:38
Score: 3
Natty:
Report link

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 }.

Reasons:
  • Blacklisted phrase (1.5): I cannot find
  • Blacklisted phrase (0.5): I cannot
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Rob P.