{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/AspNetCore/issues/3746","repository_url":"https://api.github.com/repos/aspnet/AspNetCore","labels_url":"https://api.github.com/repos/aspnet/AspNetCore/issues/3746/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/AspNetCore/issues/3746/comments","events_url":"https://api.github.com/repos/aspnet/AspNetCore/issues/3746/events","html_url":"https://github.com/aspnet/AspNetCore/issues/3746","id":375007488,"node_id":"MDU6SXNzdWUzNzUwMDc0ODg=","number":3746,"title":"Routing to same action/page reuses ambient route values","user":{"login":"poke","id":132240,"node_id":"MDQ6VXNlcjEzMjI0MA==","avatar_url":"https://avatars2.githubusercontent.com/u/132240?v=4","gravatar_id":"","url":"https://api.github.com/users/poke","html_url":"https://github.com/poke","followers_url":"https://api.github.com/users/poke/followers","following_url":"https://api.github.com/users/poke/following{/other_user}","gists_url":"https://api.github.com/users/poke/gists{/gist_id}","starred_url":"https://api.github.com/users/poke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poke/subscriptions","organizations_url":"https://api.github.com/users/poke/orgs","repos_url":"https://api.github.com/users/poke/repos","events_url":"https://api.github.com/users/poke/events{/privacy}","received_events_url":"https://api.github.com/users/poke/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-10-29T13:10:12Z","updated_at":"2018-10-29T16:02:10Z","closed_at":null,"author_association":"NONE","body":"Let’s assume I’m inside an MVC action with the default routing template (`{controller}/{action}/{id?}`) and the optional `id` route parameter is specified. So my route is for example `/Home/Test/123`.\r\n\r\nNow, inside that route, I return a `RedirectToActionResult` to the *same* action, i.e. `return RedirectToPage(nameof(Test))`. When the result is being executed, the current ambient route values are being reused, so I am being redirected to the same route `/Home/Test/123`.\r\n\r\nWhat I would instead (maybe) expected would have been a redirect to `/Home/Test` since I did not specify any route values.\r\n\r\nI am not sure if this is the intended behavior or not. When I am redirecting to a different action, the ambient values are correctly ignored. But for consistency, I would probably expect this to be true for the current route as well.\r\n\r\nInstead, when I want to clear the `id` argument, I have to explicitly specify it:\r\n\r\n```c#\r\nreturn RedirectToAction(nameof(Test), new { id = (int?)null });\r\n```\r\n\r\nThe same applies btw. to Razor pages and `RedirectToPage`.\r\n\r\nIs this the desired behavior?"},"comment":{"url":"https://api.github.com/repos/aspnet/AspNetCore/issues/comments/433968518","html_url":"https://github.com/aspnet/AspNetCore/issues/3746#issuecomment-433968518","issue_url":"https://api.github.com/repos/aspnet/AspNetCore/issues/3746","id":433968518,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMzk2ODUxOA==","user":{"login":"rynowak","id":1430011,"node_id":"MDQ6VXNlcjE0MzAwMTE=","avatar_url":"https://avatars1.githubusercontent.com/u/1430011?v=4","gravatar_id":"","url":"https://api.github.com/users/rynowak","html_url":"https://github.com/rynowak","followers_url":"https://api.github.com/users/rynowak/followers","following_url":"https://api.github.com/users/rynowak/following{/other_user}","gists_url":"https://api.github.com/users/rynowak/gists{/gist_id}","starred_url":"https://api.github.com/users/rynowak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rynowak/subscriptions","organizations_url":"https://api.github.com/users/rynowak/orgs","repos_url":"https://api.github.com/users/rynowak/repos","events_url":"https://api.github.com/users/rynowak/events{/privacy}","received_events_url":"https://api.github.com/users/rynowak/received_events","type":"User","site_admin":false},"created_at":"2018-10-29T16:02:10Z","updated_at":"2018-10-29T16:02:10Z","author_association":"MEMBER","body":"This is definitely expected and is a behaviour that's been around for a long time 😆 It's not a feature that I'm in love with, but it exists so that you can put `Url.Action()` in a page/view and have it link back to itself reliably. \r\n\r\nThis is probably the most complicated and obtuse piece of code we have in routing: https://github.com/aspnet/Routing/blob/release/2.2/src/Microsoft.AspNetCore.Routing/Template/TemplateBinder.cs#L114\r\n"}}
{"actor":{"display_login":"rynowak"}}