NameResolutionFailure在单声道,但不是.NET [英] NameResolutionFailure in Mono but not .NET

查看:830
本文介绍了NameResolutionFailure在单声道,但不是.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在HTTPS使用C#POST请求(同样的问题与HTTP)

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();

在preceding code的伟大工程,在这两个.NET和Mono的时候我没有去通过代理。当我使用代理,然后它工作时运行.NET但在单失败,出现以下

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

此外,在相同的代理服务器配置浏览器中运行工作正常。任何原因,单就同时.NET不会引发NameResolutionFailure?

Also, running in a browser with the same proxy configuration works fine. Any reason why Mono would throw a NameResolutionFailure while .NET does not?

有一个类似的计算器疑问,有一个工作创建请求时,然后加入域到request.Host使用直接的ip周围。不过,代理我不得不通过拒绝这种要求。救命啊!

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!

操作系统是Windows 7,单声道的版本是2.6.5

Operating System is Windows 7, Mono version is 2.6.5

推荐答案

提示:首先检查你的web浏览你的手机。如果这将是同样的情况 - 那么你不必担心。我有同样的情况,它发生时,仿真器没有权限净所有的时间。尝试在正常的设备。

Hint: First of all check your web browse in your phone. If it will be the same situation - then you have to worry about. I had the same situation and it happened all time when EMULATOR doesn't have permission to net. Try on normal device.

这篇关于NameResolutionFailure在单声道,但不是.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆