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.


Tuesday, March 25, 2008

Visual Studio 2008 HotFix and VB HotFix

A HotFix for VS2088 was released early in February that addresses several issues reported with Web Applications. A list of the fixed bugs can be seen on ScottGu's Blog. You can download the hot fix here.

Also, 2 days ago, the Visual Basic team released a HotFix that solves some performance issues in VS2008. Download it here


Monday, March 24, 2008

App_Offline Goodness

ASP.NET 2.0 comes with this built-in feature to easily bring down an Web Application, make changes to it and reload the application back again.

It's as easy as uploading an App_Offline.htm file in the root of your Web Application directory and you are done. Include any "under construction" or "maintenance" messages in the App_Offline.htm file that you want to display to your end users.

Once you are done, simply delete the file and ASP.NET will reload the application and everything is back to normal. For detailed info check ScottGu's blog.

Friday, March 21, 2008

Server.HtmlEncode vs HttpUtility.HtmlEncode

Have you ever wonder why there is an Html Encoding function (and other similar functions) in 3 different objects and namespaces?
The most common one is Server.HtmlEncode or System.Web.HttpContext.Current.Server.HtmlEncode.  The Server Object is an instance of the System.Web.HttpServerUtility Class and it is readily accessible through any .aspx page since they inherit from the Page object which in turn has a Server Object instance.  The second HtmlEncode function lives under System.Web.HttpUtility.  This class is basically a static version of the Server class which means that you could call the HtmlEncode function from a static function or call from another class that does not have an instance of the HttpServerUtility class. Finally,  The third HtmlEncode function is located in the Microsoft's AntiCross-Site Scripting Library. In contrast with the Server.HtmlEncode and HttpUtility.HtmlEncode functions, the later function takes a more aggressive approach by using a white-list filtering instead of a black-list.
Hope this helps.