.NET代理检测 [英] .NET proxy detection

查看:184
本文介绍了.NET代理检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,.NET检测通过Internet Explorer配置的代理服务器设置。

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

我正在写一个支持代理,并测试我成立了9鱿鱼服务器阵列,支持HTTP和HTTPs的各种认证方法的客户端应用。我有一个更新IE浏览器我选择的任何配置(代理,检测通过自动,PAC,或硬code)的脚本。

I'm writing a client application that supports proxies, and to test I set up an array of 9 squid servers to support various authentication methods for HTTP and HTTPs. I have a script that updates IE to whichever configuration I choose (which proxy, detection via "Auto", PAC, or hardcode).

我曾尝试下面的3种方法,通过.NET检测到IE浏览器的配置。在occassion我注意到,.NET拿起设置代理服务器错误。 IE浏览器设置正确,如果我浏览网页与IE浏览器,我可以看到我通过Wireshark的击中了正确的服务器。

I have tried the 3 methods below to detect the IE configuration through .NET. On occassion I notice that .NET picks up the wrong set of proxy servers. IE has the correct settings, and if I browse the web with IE, I can see I am hitting the correct servers via wireshark.

WebRequest.GetSystemWebProxy()GetProxy(目标);

GlobalProxySelection.Select.GetProxy(目标);

WebRequest.DefaultWebProxy

下面是下面的提示我:

  • 在我的脚本设置在一个网络服务器PAC文件,并更新IE浏览器的配置,然后清除IE缓存
  • .NET似乎得到一定的代理服务器配置卡壳了,我一定要设置其他配置.NET实现有一个变化。有时候,似乎挑一些随机组服务器(我敢肯定,他们不是随机的,只是一组服务器,我用了一次,而且在一些缓存的PAC文件之类的东西)。正如,我将检查目的地https://www.secure.com代理权,我可能已经IE浏览器配置,从而希望得到的http:// squidserver:18,相反它会返回HTTP :// squidserver:28(18端口运行NTLM,28运行没有身份验证)。所有鱿鱼服务器的工作。
  • 这似乎并非是在XP中,只有Vista中,2003和Windows 7的问题。
  • 在IE中硬编码的代理服务器总是工作
  • 时间总是可以解决这个问题 - 如果我离开电脑约20或30分钟后再回来,.NET拿起正确的代理服务器设置,就好像一个缓存PAC脚本过期

推荐答案

我找到了解决办法。

.NET使用WINHTTP Web代理自动发现服务来执行PAC脚本执行,而且很可能缓存的结果。简单地停止和重新启动该服务的伎俩。下面的命令行执行此操作对我来说。

.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

我按照调试器附加的詹姆斯·科瓦奇的建议,发现了这个。我已经通过code反映,并提出了失败的尝试附加调试器之前,我曾经张贴的问题,但无法破译究竟发生了什么事。暗战的选择,我又试了一次调试,几个小时后,发现在76行_AutoPWebProxyScriptEngine.cs,导致我这一发现

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. 

这篇关于.NET代理检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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