views:

14

answers:

1

Can anyone help explain why the code below fails to retrieve the html

Dim WebReqeust As WebClient = New WebClient
Dim URL as string = "http://www.professionalorganizervannuys.com"
Dim WebPage As String = WebReqeust.DownloadString(URL)

It fails on this particular URL.

Thanks in advance.

+1  A: 

Include user agent to your WebClient Headers Collection. I was able to get the html with the following.

Dim WebReqeust As WebClient = New WebClient
WebReqeust.Headers(HttpRequestHeader.UserAgent) = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)"
Dim URL as string = "http://www.professionalorganizervannuys.com"
Dim WebPage As String = WebReqeust.DownloadString(URL)
SKG
Lots of webservers are finicky about which requests they will honor. When all else fails, use Fiddler2 to watch the headers sent to a website. Compare those of a browser to those of your code and modify headers as needed.
Eyal