How do you test your Request.QueryString[] variables?

Below is an extension method that will allow you to write code like this: int id = request.QueryString.GetValue<int>(“id”); DateTime date = request.QueryString.GetValue<DateTime>(“date”); It makes use of TypeDescriptor to perform the conversion. Based on your needs, you could add an overload which takes a default value instead of throwing an exception: public static T GetValue<T>(this NameValueCollection … Read more