In my base page I need to remove an item from the query string and redirect. I can't use
Request.QueryString.Remove("foo")
because the collection is read-only. Is there any way to get the query string (except for that one item) without iterating through the collection and re-building it?
You'd have to reconstruct the url and then redirect. Something like this:
Anyway, I didn't test that or anything, but it should work (or at least get you in thye right direction)
I quick hack, saves you little. But foo will not be present for the code awaiting it in nextpge.aspx :)
Can you clone the collection and then redirect to the page with the cloned (and modified) collection?
I know it's not much better than iterating...
I found this was a more elegant solution
HttpUtility.ParseQueryString(Request.Url.Query)
return isQueryStringValueCollection
. It is inherit fromNameValueCollection
.Request.Url.GetLeftPart(UriPartial.Path)
should do this