Yesterday, after somone asked on the forums how to do a web request in an application, I posted some code that I had written a while ago, and I got some great feedback on it.  It solved a problem that I was working on, and did exactly what a few people have been asking for.

As it turns out, that was the hard way of doing things.  If you don't count { } on separate lines, that took 9 lines of code.  Someone yesterday pointed out how to do it in 4. 

So I present to you, 4 lines:

        public static string GetHTML(string url, string proxy)
        {
            System.Net.
WebClient client = new WebClient();
            
if (!String.IsNullOrEmpty(proxy))
                client.Proxy = proxy;
            
return client.DownloadString(new Uri(url));

        }

The one difference on this, it that in the one from yesterday, I was able to put a timeout of 2.5 seconds.  If the page hadn't downloaded in that, it failed.  With the code I've posted today, there doesn't seem to be a method or property to set that value.