Getting non string values from the querystring can be a chore if you need to read alot of values; parsing to the required type and ensuring the querystring value doesn't cause an exception ("adsf" cannot become an integer) can add alot of code to each page. So a long while ago I created a small helper class to do this for me, which I've now upgraded (after reading a blog entry by ScottH about TypeConverters) to use generics and extension methods. I've also included methods to get a value from the Request.Form property. using System;
using System.Web;
using System.ComponentModel;
namespace LukeSmith.Web
{
...
I had a comment left recently on a post I made a few months ago (HttpRequest QueryValue extension methods), I was going to reply in the comments but felt it deemed a post in itself. I agree 100% with the commenter about avoiding throwing exceptions and I try to always use the Tester-Doer pattern. As you can see in the code in the post I am using this pattern. However the ConvertFromInvariantString method will throw an exception in cases where 'asdf' is trying to be converter to an int, and at the time I couldn't find a...