I am making HTTPS POST 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 preceding code works great in both .NET and Mono when I don't have to go through a proxy. When I have to use a proxy, then it works when run on .NET but in Mono fails 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
Also, running in a browser with the same proxy configuration works fine. Any reason why Mono would throw a NameResolutionFailure while .NET does not?
There was a similar stackoverflow question that had a work around of using the direct ip when creating the request and then adding the domain to the request.Host. However, the proxy I have to go through rejects this kind of request. Help!
Operating System is Windows 7, Mono version is 2.6.5