How can I remove item from querystring in asp.net using c#?

Barbaros Alp picture Barbaros Alp · Feb 9, 2009 · Viewed 110.8k times · Source

I want remove "Language" querystring from my url. How can I do this? (using Asp.net 3.5 , c#)

Default.aspx?Agent=10&Language=2

I want to remove "Language=2", but language would be the first,middle or last. So I will have this

Default.aspx?Agent=20

Answer

xcud picture xcud · Feb 9, 2009

If it's the HttpRequest.QueryString then you can copy the collection into a writable collection and have your way with it.

NameValueCollection filtered = new NameValueCollection(request.QueryString);
filtered.Remove("Language");