Generating URLs for a different action on the same controller reuses ambient values
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
The [documentation](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-3.1#endpoint-routing-differences-from-earlier-versions-of-routing) 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](https://github.com/danports/aspnetcore-routingtest), 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.
Contributor guide
Assessment
This issue has not been assessed yet.