web.config文件中的<default proxy> 的知识

本文介绍如何在.NET应用程序中配置HTTP代理服务器。通过编辑machine.config文件,可以指定全局HTTP代理设置,适用于桌面应用及ASP.NET应用。文章详细说明了如何配置&lt;defaultProxy&gt;元素,并介绍了如何设置代理地址和本地绕过等选项。

这个元素指定了HTTP请求Internet资源时使用的代理服务器.


 
<configuration>
    <system.net>
        <defaultProxy>

 

<defaultProxy>元素定义了被GlobalProxySelection类使用的代理服务器信息. 任何没有制定代理属性的HttpRequest都会使用由defaultProxy定义的代理.

 

总的来说, 标准桌面应用程序中, .NET运行时会使用由Microsoft Internet Explorer中的代理服务器配置. 如果你访问你的web service存在的站点, 那么你就能够不修改任何配置地用.NET运行时来进行访问, 因为你的配置是从你的user profile中获取的.

 

.NET运行时并不支持自动探测代理的服务的脚本. 如果IE浏览器使用自动配置这个选项来确定HTTP代理配置, 你就能够手动地在machine.config文件中, 配置全局的HTTP代理配置. 同样地, 当你在没有加载user profile的情况下, 使用.NET运行时来访问一个XML web service(比如说, 你从一个ASP.NET页面调用web service), 你就必须在machine.config中进行配置.

 

To configure the HTTP proxy settings for desktop and ASP.NET applications, follow these steps:

  1. Edit the Machine.config file. For the .NET Framework, the default location for this file is C:\WINNT\Microsoft .NET\Framework\v1.0.2914\CONFIG\machine.config.
  2. Locate the \configuration\system.net\defaultProxy element in the XML.
  3. Change the child <proxy> element to the following, where http://myproxyserver indicates your HTTP proxy server:

    <proxy usesystemdefault="false" 
           proxyaddress="http://myproxyserver" 
           bypassonlocal="true" /> 
    						

    The bypassonlocal attribute indicates that requests to hosts whose names contain a period (.) should not be sent through the proxy.

  4. If other addresses need to bypass the proxy server, you can add them by creating a <bypasslist> element as a child of the <defaultProxy> element. The <bypasslist> syntax should resemble the following:

    <bypasslist>
        <add address="localdomain.com|localdomain2.com" />
    </bypasslist> 
    						

    This syntax avoids sending any requests to localdomain.com and localdomain2.com through the HTTP proxy. The address attribute is actually a string that contains a regular expression. For more information on the syntax of regular expressions, see the information on System.Text.RegularExpresions in the .NET runtime documentation.

  5. Save the changes to Machine.config and restart the application.

http://support.microsoft.com/kb/307220/

http://msdn.microsoft.com/en-us/library/aa903360%28VS.71%29.aspx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值