Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Created Unassigned: Current route values from query string implicitly used by Url.Action [1599]

$
0
0
MVC Futures' `Url.Action<TController>` allows to specify action parameters directly, as values in lambda expression, but it fails when value passed is null and its name matches query string parameter from current request - query string value is re-used instead of explicitly-stated null.

Null is put under the appropriate key in the `RouteValuesCollection`, it then goes down to `Route.GetVirtualPath` method, which also takes the current route values from the `RequestContext`. And then the evil happens - the low-level `System.Web.Routing`'s method `ParsedRoute.Bind` ignores the null value and - bang - it takes the value from the current request, if any accidentally matches by the parameter name.

It means that when trying to build an URL that passes parameter "param" equal to null and the current request accidentally have parameter named also "param" (regardless of its type or existence of any logical connection), the request's "param" value will be passed instead our explicitly demanded null value. And I can see no way to pass null in this case.

See my blog post for more detailed description and solution proposal: [ASP.NET MVC: Current route values implicitly used by Url.Action](http://notherdev.blogspot.com/2013/10/aspnet-mvc-current-values-used-by-url-action.html)

Viewing all articles
Browse latest Browse all 7215

Trending Articles