WebClient in Windows Service
2012-06-01 09:28
183 查看
前提:
1.如果你访问网络需要使用代理
2.如果你控制台程序使用WebClient访问或下载文件时正常,但作为Windows Service使用 WebClient 时失败。其中报错包括但不限于:操作超时(The operation has timed out) / 无法连接到远程服务器(Unable to connect to the remote server)
请尝试在代码中定义代理地址:
1.如果你访问网络需要使用代理
2.如果你控制台程序使用WebClient访问或下载文件时正常,但作为Windows Service使用 WebClient 时失败。其中报错包括但不限于:操作超时(The operation has timed out) / 无法连接到远程服务器(Unable to connect to the remote server)
请尝试在代码中定义代理地址:
var client = new WebClient(); if (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["WebProxyUri"])) { IWebProxy proxyObject = new WebProxy(System.Configuration.ConfigurationManager.AppSettings["WebProxyUri"], true, new[] { @"172.*" }); client.Proxy = proxyObject; }
相关文章推荐
- web service in Windows Phone
- Web.Config - create WCF REST Service and host in Windows Azure
- SPRING IN ACTION 第4版笔记-第九章Securing web applications-008-使用非关系型数据库时如何验证用户(自定义UserService)
- Setting Web Service and JCA Adapter Endpoints Dynamically in Oracle SOA Suite
- WebService in MOSS
- Windows Azure Cloud Service (43) 使用Azure In-Role Cache缓存(2)Dedicated Role
- How to test Service Layer in Spring web app
- Web service in DW.mx
- .NET SOAP Web Service client and Borland SOAP server
- javax.xml.ws.WebServiceException: No Content-type in the header!
- How To: Call a Java EE Web Service from a .Net Client
- [Windows Azure] Create and use a reporting service in Windows Azure SQL Reporting
- mono 调用windows webService
- Visual Studio2015发布web站点到windows azure Cloud Service(PAAS)
- Cookieless Session In WebService
- java webservice server 和client 参数和返回值
- create a deployment package for Webservice in Visual Studio
- How to use Security Policies in WebLogic SCA Web Service Binding
- Microsoft Windows DHCP Client Service Remote Buffer Overflow
- Axis2 Webservice new RPCServiceClient()错误的问题