문제

해당 설정을 감지/재사용 할 수 있습니까?

어떻게 ?

내가 얻는 예외는 이것이 연결하는 동안 예외입니다. http://www.google.com

System.Net.WebException: Unable to connect to the remote server --->
  System.Net.Sockets.SocketException: A connection attempt failed because the
  connected party did not properly respond after a period of time, or established
  connection failed because connected host has failed to respond 66.102.1.99:80

  at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, 
     SocketAddress socketAddress)
  at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
  at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure,
     Socket s4, Socket s6, Socket& socket, IPAddress& address,
     ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout,
     Exception& exception)
  --- End of inner exception stack trace ---
  at System.Net.HttpWebRequest.GetResponse()
  at mvcTest.MvcApplication.Application_Start() in
     C:\\home\\test\\Application1\\Application1\\Program.cs:line 33"
도움이 되었습니까?

해결책

httpwebrequest는 실제로 기본적으로 IE 프록시 설정을 사용합니다.

만약 너라면 ~하지 않다 그것들을 사용하려면, .proxy proprty를 null (프록시 없음) 또는 선택의 프록시 설정으로 구체적으로 무시해야합니다.

 HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://news.bbc.co.uk");
 //request.Proxy = null; // uncomment this to bypass the default (IE) proxy settings
 HttpWebResponse response = (HttpWebResponse)request.GetResponse();

 Console.WriteLine("Done - press return");
 Console.ReadLine();

다른 팁

HTTPWebRequest가 기본적으로 올바른 프록시 세부 정보를 선택하지 않고 사용 된 FIDEALCREDELFINS를 설정하지 않은 매우 비슷한 상황을 얻었습니다. 그러나 코드의 설정을 강제로 처리하면 다음과 같이 처리했습니다.

IWebProxy proxy = myWebRequest.Proxy;
if (proxy != null) {
    string proxyuri = proxy.GetProxy(myWebRequest.RequestUri).ToString;
    myWebRequest.UseDefaultCredentials = true;
    myWebRequest.Proxy = new WebProxy(proxyuri, false);
    myWebRequest.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
}

또한 기본 자격 증명을 사용하기 때문에 사용자에게 세부 정보를 요청해서는 안됩니다.

이것은 매우 유사한 문제에 대해 여기에 게시 된 내 대답의 복제본입니다. C#의 프록시 기본 인증 : HTTP 407 오류

ISA 서버 에서이 문제를 해결하는 데 문제가있는 사람들의 경우 다음과 같은 방식으로 프록시를 설정하려고 할 수 있습니다.

IWebProxy webProxy = WebRequest.DefaultWebProxy;
webProxy.Credentials = CredentialCache.DefaultNetworkCredentials;
myRequest.Proxy = webProxy;

이는 기본적으로 webRequest.proxy가 명시 적으로 설정되지 않은 경우 (기본적으로 설정됩니다. WebRequest.DefaultWebProxy).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top