Friday, July 30, 2010

How to: List all Query string variables in C#

This is how you can do it in C#, Either of will work for getting Query string values

for (int i = 0; i < Request.QueryString.Count; i++)
{                 
    Response.Write(Request.QueryString.Keys[i].ToString()+ ":"+Request.QueryString.Keys[i].ToString()+"<br/>");
}
foreach (string key in Request.QueryString.Keys)
{
    Response.Write(key+ ":"+Request.QueryString[key]+"<br/>");
}
  

No comments:

Post a Comment