I am trying to do a httpwebrequest with a proxy and everytime I try to do it I get this error:
The underlying connection was closed: An unexpected error occurred on a receive.
This is my httpwebrequest code. I removed the postData and the sites I am trying to request to since I am planning to sell my program and dont want leechers to get a hold of my code.
Code:string MyProxyHostString = txtBoxIP.Text; int MyProxyPort = System.Convert.ToInt32(txtBoxPort.Text); System.Net.ServicePointManager.Expect100Continue = false; string postdata = ""; UTF8Encoding encoding1 = new UTF8Encoding(); byte[] bytedata = encoding1.GetBytes(postdata); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(""); request.Proxy = new WebProxy(MyProxyHostString, MyProxyPort); request.Method = "POST"; request.KeepAlive = false; request.ContentType = "application/x-www-form-urlencoded"; request.Referer = ""; request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"; request.ContentLength = bytedata.Length; Stream postreqstream2 = request.GetRequestStream(); postreqstream2.Write(bytedata, 0, bytedata.Length); postreqstream2.Close(); HttpWebResponse response = default(HttpWebResponse); response = (HttpWebResponse)request.GetResponse(); StreamReader stream2 = new StreamReader(response.GetResponseStream()); StreamReader reader2 = new StreamReader(response.GetResponseStream());




Reply With Quote