Search code examples
c#query-stringnamevaluecollection

Setting values with commas in namevaluecollection


I am using the following code to access and manipulate query string

NameValueCollection qs = HttpUtility.ParseQueryString(Request.Url.Query);
qs.Set("OID", "5,6,7");
Response.Redirect( absolutepath + "?" + qs);

The problem is that query string ends up like this "something.aspx?OID=5%2c6%2c7" instead of something.aspx?OID=5,6,7

How can I format qs to get commas instead of %2c?


Solution

  • Use HttpUtility.UrlDecode(qs);