|
-
Mar 8th, 2010, 12:10 PM
#1
Thread Starter
Fanatic Member
WebClient.DownloadString 403 Error
I've been testing using WebClient.DownloadString and sometimes I encounter an error: "The remote server returned an error: (403) Forbidden". It is based upon which url I use. For instance, this works:
Code:
Dim wc As New Net.WebClient
Dim strResult As String = String.Empty
Try
strResult = wc.DownloadString("http://en.wikipedia.org/wiki/President_of_the_United_States")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly, "ex")
End Try
But this doesn't:
Code:
Dim wc As New Net.WebClient
Dim strResult As String = String.Empty
Try
strResult = wc.DownloadString("http://en.wikipedia.org/wiki/Barack_Obama")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly, "ex")
End Try
The only difference is the url. The only difference I can see in the pages is that the second page is a bit larger. However, I also tried "http://en.wikipedia.org/wiki/The_Holocaust", which is larger than the Obama page (it would appear) and it worked just fine. I can load the Obama page in a WebBrowser just fine, so I have no idea why DownloadString is failing on that.
Any thoughts? Thanks.
Sorry about using political pages, I just during testing that the Obama pages always fails.
VB.Net 2008
.Net Framework 2.0
"Must you breathe? 'Cause I need heaven..."
-
Mar 8th, 2010, 01:00 PM
#2
Re: WebClient.DownloadString 403 Error
The Obama page worked fine for me. Could it be a firewall blocking it?
-
Mar 8th, 2010, 01:17 PM
#3
Thread Starter
Fanatic Member
Re: WebClient.DownloadString 403 Error
"The Obama page worked fine for me. Could it be a firewall blocking it? "
See, that's what I thought. But I originally ran into this problem while testing at my friend's house (U-verse package, he just plugged in the router, no special settings). But, I have the same problem with the same page here at work. I can load the Obama page in Firefox (or a WebBrowser control), it just won't play nice with DownloadString. I've seen this error on a lot of wikipedia pages (though I didn't save any of the other examples) as well.
Though, if you can get it without problems, one would think it would be some of network issue.
VB.Net 2008
.Net Framework 2.0
"Must you breathe? 'Cause I need heaven..."
-
Mar 9th, 2010, 12:09 PM
#4
Thread Starter
Fanatic Member
Re: WebClient.DownloadString 403 Error
I search the forums just for "403" and got a few more results.
On this thread:
http://www.vbforums.com/showthread.p...&highlight=403
User Banjo seemed to have a similar problem and stated "Just to let you know it was an ip block thing, it's a secure site thats why. Thanks for the help."
Does that mean Banjo resolved it, or just gave up? If Banjo did resolve the problem, the thread doesn't indicate that. If the problem was resolved, can anyone glean from that thread how Banjo resolved it?
I don't know if wikipedia is a secure site, but I doubt it as this is a problem that I find very rarely.
Thanks
VB.Net 2008
.Net Framework 2.0
"Must you breathe? 'Cause I need heaven..."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|