Click here to Skip to main content
14,830,769 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm trying to get the html code of a website via some proxy server so that I can hide my IP address and increase response speed when doing several webrequests. However my code is not working and keeps giving errors like:

"The remote server returned an error: (500) Internal Server Error."


"Cannot send a content-body with this verb-type."

Any help would be very much appreciated. Here my code:

Dim sData As System.Text.StringBuilder = New System.Text.StringBuilder()
Dim bData() As Byte = system.Text.UTF8Encoding.UTF8.GetBytes(sData.ToString())
Dim myProxy As New WebProxy("", True)
Dim myWebRequest As WebRequest
Dim myWebResponse As WebResponse
myWebRequest = CType(WebRequest.Create(url), WebRequest)
myWebRequest.Proxy = myProxy
myWebRequest.UseDefaultCredentials = True
myWebRequest.Method = "POST"
myWebRequest.ContentType = "text/xml"
myWebRequest.ContentLength = bData.Length
myWebRequest.Timeout = 5000

myWebResponse = CType(myWebRequest.GetResponse(), WebResponse)

Dim postStream As System.IO.Stream = myWebRequest.GetRequestStream()
postStream.Write(bData, 0, bData.Length)
htmlStream = New System.IO.StreamReader(myWebResponse.GetResponseStream())

Thank you very much !
Sergey Alexandrovich Kryukov 27-Dec-15 15:58pm
Did you really setup the proxy? :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900