Skip to content

RedirectToAction in Core 3.1 MVC route values don't pass through if param has default #22303

Open
@Budsy

Description

@Budsy

This action won't load the parameter with a passed route value from a redirection because it has a default.

public IActionResult HelloWorld(string message="")
{
    ViewData["Message"] = message;  // If sent 'Howdy' from SendMsg() message will be empty 
    return View(); 
}
public IActionResult() SendMsg()
{
    return RedirectToAction("HelloWorld", new{ message="Howdy" });
}
/***********************************************/
// But this works ok if there is no default value on the param:
public IActionResult HelloWorld(string message)
{
    ViewData["Message"] = message;  // message will hold 'Howdy' now
    return View(); 
}

I never observed this before, so it might be a long-standing issues, normal behavior, or whatever.

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-mediumThis issue impacts approximately half of our customersarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-routingseverity-majorThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions