采用动态与WPAD脚本WebProxy [英] Dynamically using a WebProxy with WPAD script

查看:571
本文介绍了采用动态与WPAD脚本WebProxy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图调用Web服务。我需要使用使用WPAD脚本代理。该URL这个WPAD脚本是应用程序的不同的部署不同的。

I am trying to call a webservice. I need to use a proxy that uses a WPAD script. The URL to this WPAD script is different for different deployments of the application.

虽然IE浏览器有正确的proxysettings,在应用程序运行为在本地系统帐户下运行Windows服务,所以应用程序不知道IE浏览器,设置这个Windows用户。

Although IE has the correct proxysettings, the application is running as a windows service running under Local System account, so the application does not know the IE-settings for this windows-user.

把以下内容中的app.config作品:

Putting the following in app.config works:

<system.net>
    <defaultProxy enabled="true" useDefaultCredentials="true" >
        <proxy autoDetect="True" scriptLocation="http://url.to/wpad.dat"/>
    </defaultProxy>
</system.net>

但是,这具有它不能由用户配置的限制。有没有办法从动态做了上述(C# - )code?我还怀疑上面会改变web服务的行为不应该通过代理(但我没有验证)。

But this has the restriction that it cannot be configured by the user. Is there a way to do the above dynamically from (C#-)code? I also suspect the above will change behaviour of webservices that should not go through a proxy (but I have not verified that).

http://msdn.microsoft.com/en -us /库/ system.net.webproxy.aspx 我发现有帮助的文字:(对于演示如何使用WPAD功能的示例,请参阅IWebProxyScript类的文档)。但我还没有发现例如:(

At http://msdn.microsoft.com/en-us/library/system.net.webproxy.aspx I found the helpful text: "(For an example that demonstrates using the WPAD feature, see the documentation for the IWebProxyScript class.)" but I have not found the example :(.

推荐答案

这篇文章在code项目说明如何使用Windows API来执行PAC脚本并返回正确的代理服务器的详细信息对于一个给定的URL: HTTP://www.$c$cproject.com/Articles / 12168 /使用-PAC-文件代理

This article on code project shows how to use windows APIs to execute the PAC script and return the correct proxy details for a given url: http://www.codeproject.com/Articles/12168/Using-PAC-files-proxy

您可以使用该功能查找代理服务器的详细信息,然后直接配置Web服务对象代理,或更改WebRequest.DefaultProxy。

You could use the function to find out the proxy details, and then configure the web service objects proxy directly, or change WebRequest.DefaultProxy.

这篇关于采用动态与WPAD脚本WebProxy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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