lol
lol

Reputation: 93

adding keys and values to query string

I am trying to do :

foreach (JProperty o in obj.Properties())
{
   string ke = o.Name.ToString();
   string va = o.Value.ToString();
   HttpContext.Current.Request.QueryString.Add(ke,va);
}

but it gives me the error "collection is read-only"

HOW can I add values to querystring then ?

Thanks

Upvotes: 0

Views: 154

Answers (1)

misha130
misha130

Reputation: 5726

Request.QueryString is the url you recieve from the server. You cant change it. What you can do is execute a response redirect with the query string like so:

string qs = "?";
foreach (JProperty o in obj.Properties())
{
   qs += o.Name.ToString();
   qs += "=" + o.Value.ToString() + "&";
}
Response.Redirect("url/index" + qs);

Upvotes: 1

Related Questions