You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Url.QueryParams has always been backed by an IDictionary<string, object>. While very handy in most cases, inevitably the problem came up of how to deal with this perfectly legitimate scenario:
x=1&x=2&x=3
In order to not introduce a breaking change at the time, I took advantage of the fact that the values are objects and simply returned an array for url.QueryParams["x"]. Checking if it's an array is not only clunky, it's also easy to forget, which could lead to bugs. The new collection types introduced in #541 are better suited for this.
What's breaking
Instead of this:
varx=url.QueryParams["x"];// is it an array? better check!
You will now do this:
varx=url.QueryParams.FirstOrDefault("x");// always returns a single valuevarxs=url.QueryParams.GetAll("x");// always returns a collection
With QueryParams["x"] gone it's obviously not writeable anymore either. Use QueryParams.AddOrReplace instead.
What's not breaking
The most typical action involving query params is writing them using fluent methods directly on Url:
Related to #541
Url.QueryParams
has always been backed by anIDictionary<string, object>
. While very handy in most cases, inevitably the problem came up of how to deal with this perfectly legitimate scenario:In order to not introduce a breaking change at the time, I took advantage of the fact that the values are
object
s and simply returned an array forurl.QueryParams["x"]
. Checking if it's an array is not only clunky, it's also easy to forget, which could lead to bugs. The new collection types introduced in #541 are better suited for this.What's breaking
Instead of this:
You will now do this:
With
QueryParams["x"]
gone it's obviously not writeable anymore either. UseQueryParams.AddOrReplace
instead.What's not breaking
The most typical action involving query params is writing them using fluent methods directly on
Url
:None of these are changing in semantics or behavior.
The text was updated successfully, but these errors were encountered: