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:
- 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.
- Locate the \configuration\system.net\defaultProxy element in the XML.
- 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.
- 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.
- 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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律