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

这个元素指定了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

原文地址:https://www.cnblogs.com/awpatp/p/1645087.html