I am making POST HTTPS requests (same problem with HTTP) using C #
byte[] byteArray = Encoding.UTF8.GetBytes("var1=blah&var2=hah"); HttpWebRequest request = (HttpWebRequest)(WebRequest.Create("https://www.example.com")); request.Credentials = CredentialCache.DefaultCredentials; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = byteArray.Length; request.Method = "POST"; Stream dataStream = request.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); WebResponse response = request.GetResponse();
The previous code works fine both in .NET and in Mono, when I do not need to go through a proxy. When I have to use a proxy server, it works when .NET starts, but in Mono it does not work with the following
WebException: Error: NameResolutionFailure at System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 at System.Net.HttpWebRequest.GetRequestStream () [0x00000] in <filename unknown>:0
In addition, working in a browser with the same proxy configuration works fine. Any reason Mono throws NameResolutionFailure and .NET doesn't?
There was a similar stackoverflow question that worked using direct ip when creating a request and then adding a domain to request.Host. However, the proxy I must go through rejects this request. Help!
Operating System - Windows 7, Mono Version - 2.6.5
source share