.NET proxy detection

前端 未结 2 968
天命终不由人
天命终不由人 2021-02-07 18:10

I am having an issue with .NET detecting the proxy settings configured through internet explorer.

I\'m writing a client application that supports proxies, and to test I

相关标签:
2条回答
  • 2021-02-07 18:46

    I found the solution.

    .NET uses the "WinHttp Web Proxy Auto Discovery Service" to perform PAC script execution, and probably caches the results. Simply stopping and restarting this service does the trick. The following command line does this for me.

    NET STOP WinHttpAutoProxySvc
    NET START WinHttpAutoProxySvc
    

    http://wiki.blackviper.com/wiki/WinHTTP_Web_Proxy_Auto-Discovery_Service

    I found this by following James Kovacs' suggestion of attaching the debugger. I had already reflected through the code and made a failed attempt to attach a debugger before I ever posted the question, but could not decipher exactly what was happening. Running out of options, I tried debugging again, and after several hours found the following comment in _AutoPWebProxyScriptEngine.cs on line 76 that led me to this discovery

            // In Win2003 winhttp added a Windows Service handling the auto-proxy discovery. In XP using winhttp
            // APIs will load, compile and execute the wpad file in-process. This will also load COM, since 
            // WinHttp requires COM to compile the file. For these reasons, we don't use WinHttp on XP, but
            // only on newer OS versions where the "WinHTTP Web Proxy Auto-Discovery Service" exists. 
    
    0 讨论(0)
  • 2021-02-07 18:53

    I had the same issue and I succeded getting/setting the proxy setting in registry:

    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]   
    "ProxyServer"="<your proxy IP address>:8080"
    "ProxyEnable"=dword:00000001
    "ProxyOverride"="<local>"
    
    0 讨论(0)
提交回复
热议问题