Skip to content

Generating URLs for a different action on the same controller reuses ambient values #18400

Open
@danports

Description

@danports

The documentation states that "In ASP.NET Core 2.2 or later, both [conventional and attribute] routing invalidate [ambient] values when linking to another action." However, this only seems to be the case for actions on another controller. I am unsure whether this is a bug or the expected behavior with unclear or incorrect documentation.

Repro: Run this sample project, click the Orders tab in the navigation bar, select an order from the list, and then observe that the URL for the Orders tab in the navigation bar as generated on the order details page is /Orders/5/Index rather than the expected /Orders (since the documentation says the ambient value for id shouldn't be reused since this is a different action). Note also that the Home and Privacy navigation links on the order details page do not reuse ambient values and do not include id in their URLs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-fewThis issue impacts only small number of customersarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesbugThis issue describes a behavior which is not expected - a bug.feature-routingseverity-minorThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions