2013-10-20 1 views
1

외부 웹 서비스를 호출하는 ASP.NET 4.5 웹 응용 프로그램이 있습니다. 환경에서는 인증 된 프록시 서버를 통과하기 위해 인터넷 액세스가 필요합니다.ASP.NET 응용 프로그램에서 제대로 작동하는 인증 된 프록시 서버를 얻으려면 어떻게해야합니까?

내 dev PC (Win7)에서 다음 구성이 정상적으로 작동합니다.

<system.net> 
    <defaultProxy useDefaultCredentials="true" enabled="true"> 
    <proxy usesystemdefault="True" autoDetect="True" /> 
    </defaultProxy> 
</system.net> 

위의 구성은 테스트 서버에 적용 할 때 작동하지 않습니다. 테스트 서버는 IIS 7이 설치된 Windows Server 2008입니다. 내 자격 증명을 사용하여 프록시 서버를 인증 할 수 있도록 응용 프로그램 풀 ID를 내 사용자 자격 증명으로 설정했습니다.

IWebProxy의 사용자 지정 구현을 만들면 테스트 서버에서 프록시를 사용할 수 있습니다.

public class ManualProxy : IWebProxy 
{ 
    private readonly Uri _proxy; 
    private static readonly NameValueCollection AppSettings = ConfigurationManager.AppSettings; 

    public ManualProxy() 
    { 
     _proxy = new Uri(AppSettings["ManualProxy.Proxy"]); 
    } 


    #region IWebProxy 

    ICredentials IWebProxy.Credentials 
    { 
     get 
     { 
      return new NetworkCredential(AppSettings["ManualProxy.Username"], AppSettings["ManualProxy.Password"]); 
     } 
     set 
     { 
      throw new NotImplementedException(); 
     } 
    } 

    Uri IWebProxy.GetProxy(Uri destination) 
    { 
     return _proxy; 
    } 

    bool IWebProxy.IsBypassed(Uri host) 
    { 
     return false; 
    } 

    #endregion 
} 

구성입니다.

<defaultProxy useDefaultCredentials="false" enabled="true"> 
    <module type="MyNamespace.ManualProxy, MyAssembly"/> 
</defaultProxy> 

사용자 정의 프록시는 내 dev에 PC에와 IIS 응용 프로그램 풀의 정체성에 대해 동일한 자격 증명 내 자격 증명을 사용하여 인증하도록 구성되어 있습니다.

이상적으로 사용자 지정 프록시가 필요하지 않습니다. web.config의 기존 옵션을 사용하여 프록시 서버를 올바르게 구성하려면 어떻게합니까?

내가 제대로하지 못하는 것이 있습니까?

답변

2

자동 검색에 의존하지 않고 프록시 주소를 강제로 설정하면 문제가 해결됩니다.

<system.net> 
    <defaultProxy useDefaultCredentials="true" enabled="true"> 
     <proxy usesystemdefault="False" autoDetect="False" proxyaddress="http://proxy:8080" /> 
    </defaultProxy> 
    </system.net> 
+0

내 문제를 해결하기 위해 IWebProxy.Credentials에 대한 설정 도구를 구현해야했습니다. 그러나 나는이 해결책으로 나의 problema를 해결한다. 고맙습니다. –

관련 문제