A tip when working with QueryStrings

(Note: This blog post was originally published under my old domain(codesmiles.com), here. Web Archive link. We still use QueryStrings for many reasons even though we have other methods to deal with HTTP requests to web applications. And when working with QueryStrings, I hate to type Request.QueryString(“blah”), Request.QueryString(“blahblah”), Request.QueryString(“blahblahblah”), etc., again and again when I need to. This is more tiring if there are more number of QueryString items to deal with. If you note, Request.QueryString is actually a NameValueCollection. So in suitable situations I would love to use a NameValueCollection object with a short name instead of Request.QueryString(“blah”) 😉 as shown below. This saves time and provides a little better coding experience. NameValueCollection q = Request.QueryString; Response.Write(“name” + q[“name”]); Response.Write(“address1” + q[“address1”]); Response.Write(“address2” + q[“address2”]); Response.Write(“city” + q[“city”]); Response.Write(“country” + q[“country”]);