I’m sure I’m over looking something simple, but I can’t remember to save my life how to change a “GET” variable’s value.
For example, say I have the web address www.food.com/food.aspx?foodType=Healthy
I know Request.QueryString["foodType"] can be used to retrieve the value, but if I want to say, change “Healthy” to “Unhealthy“, how would I change the value on post back?
I’m using a on-click event right now for my button, but I am stuck on changing the value of “foodType.” I tried using Request.QueryString.Add("foodType", "UnHealthy"); but that did not work.
Any ideas?
I’m not sure what your use case is, but you cannot modify the collection. As @Grant mentioned already the collection is read only.
If you use look at the source for
HttpRequestit creates theQueryStringcollection like this:That second parameter sets the collection as read only.