Tuesday, April 8, 2008

ClientQueryString Page Property

I was browsing through the Page class in System.Web.UI assembly and I run into the "ClientQueryString" property. Here is its signature:

Public Readonly Property ClientQueryString As String.

It returns the page's querystring in an encoded fashion (so one would have to use

HttpServerUtility.UrlDecode to decode the querystring.) Inspecting the source code I did noticed a couple of interesting things: The property goes through the Page.s_systemPostFields and adds them to a "black list" which will be excluded from the string returned by the property. Also, and I think pretty neat, is the way the black list gets excluded from the query string results: The Request.QueryString gets casted as an HttpValueColletion object and then it invokes its overriden "ToString" Method to which the "blacklist" is passed to in its arguments. (excludeKeys is a Hashtable of "keys to exclude".)
Me._clientQueryString = DirectCast(Me.Request.QueryString, HttpValueCollection).ToString(True, excludeKeys
I thought that was pretty cool, no need to loop through the collection, just pass it as an argument and the .ToString takes care of it.

With this property you can't get an individual querystring value since you can't specify a "key name". You get all of query string values. I guess this is useful if you need to pass on the querystring to another page or if for some reason you need perform some custom parsing and manipulation on the query string.

Saturday, April 5, 2008

Every Build You Break

This is hilarious. Roy Osherove posted a video on YouTube.com where he sang "Every build you break" to a live audience.