Skip to content

Anchor tag helper should allow for multiple route value parameters with the same name #40556

Open
@nfplee

Description

@nfplee

The route values property in the anthor tag helper only allows for route values to have a single value since it of type IDictionary<string, string>. Therefore when you say:

<a asp-action="Index" asp-all-route-data="@Context.Request.Query.ToDictionary(kvp => kvp.Key, kvp => (string)kvp.Value)">Link 1</a>

If the query string is ?filter=Red&filter=Green it produces:

<a href="/shop?filter=Red,Green">Link 1</a>

However if you say:

<a href="@Url.Action("Index", Context.Request.Query.ToDictionary(kvp => kvp.Key, kvp => (object?)kvp.Value))">Link 1</a>

It correctly produces:

<a href="/shop?filter=Red&amp;filter=Green">Link 1</a>

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-routinginvestigate

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions