System.Net.WebException was caught
HResult=-2146233079
Message=An exception occurred during a WebClient request.
Source=System
StackTrace:
at System.Net.WebClient.OpenRead(Uri address)
at System.Net.WebClient.OpenRead(String address)
at Client.Program.GetAllEmployees(String contentType, String accept) in h:\帮助页面与自动消息格式(JSONXML)选择\Client\Program.cs:line 62
InnerException: System.Configuration.ConfigurationErrorsException
HResult=-2146232062
Message=Error creating the Web Proxy specified in the 'system.net/defaultProxy' configuration section.
Source=System
BareMessage=Error creating the Web Proxy specified in the 'system.net/defaultProxy' configuration section.
Line=0
StackTrace:
at System.Net.Configuration.DefaultProxySectionInternal.GetSection()
at System.Net.WebRequest.get_InternalDefaultWebProxy()
at System.Net.HttpWebRequest..ctor(Uri uri, ServicePoint servicePoint)
at System.Net.HttpRequestCreator.Create(Uri Uri)
at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
at System.Net.WebRequest.Create(Uri requestUri)
at System.Net.WebClient.GetWebRequest(Uri address)
at System.Net.WebClient.OpenRead(Uri address)
InnerException: System.Net.Sockets.SocketException
HResult=-2147467259
Message=An invalid argument was supplied
Source=System
ErrorCode=10022
NativeErrorCode=10022
StackTrace:
at System.Net.SafeCloseSocketAndEvent.CreateWSASocketWithEvent(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType, Boolean autoReset, Boolean signaled)
at System.Net.NetworkAddressChangePolled..ctor()
at System.Net.AutoWebProxyScriptEngine.AutoDetector.Initialize()
at System.Net.AutoWebProxyScriptEngine.AutoDetector.get_CurrentAutoDetector()
at System.Net.AutoWebProxyScriptEngine..ctor(WebProxy proxy, Boolean useRegistry)
at System.Net.WebProxy.UnsafeUpdateFromRegistry()
at System.Net.WebProxy..ctor(Boolean enableAutoproxy)
at System.Net.Configuration.DefaultProxySectionInternal..ctor(DefaultProxySection section)
at System.Net.Configuration.DefaultProxySectionInternal.GetSection()
InnerException:

上述的错误来自于下面的代码:

 WebClient webClient = new WebClient();

                var stream = webClient.OpenRead("http://www.cnblogs.com/");
using (StreamReader reader = new StreamReader(stream))
{
Console.WriteLine(reader.ReadToEnd());
}

  

上面的错误让我纠结了好久,仅仅是一个简单的webclient请求,怎么都不通??

百度了一个办法?

http://codebender.denniland.com/system-net-webexception-an-exception-occurred-during-a-webclient-request/

试了,还是不行,看到了system.net/defaultProxy 关键词,以为是公司网络问题,于是下班之后在家里的网络试了一下,

竟然代码通过了,所以我的怀疑是没问题的,

但是毕竟要在公司开发啊,回到公司,果然错误依旧

然后找了同事帮我看,看着看着 ,灵机一动 我想起来了,代码不是放在本地,是放在一个共享里,

。。。。。。。。。

这个错误的原因来的太纠结了,果然 把代码拷贝到本地,错误也就没了,

真是自己折磨自己啊

An exception occurred during a WebClient request的更多相关文章

  1. [已解决]An unhandled exception occurred while processing the request.

    An unhandled exception occurred while processing the request. InvalidOperationException: The layout ...

  2. ActiveMQ:Exception occurred while processing this request, check the log for more information!

    出现上面错误的原因有以下两种 1 jdk的版本和activemq的版本不符 安装完ActiveMQ之后,通过http://IP:8161登陆到控制台. 通过测试代码给服务端发送队列消息,在控制台点击q ...

  3. Exception occurred while processing this request, check the log for more information!安装ActiveMq-5.14.1 配置安全验证报错解决

    安装ActiveMq-5.14.1  并配置了安全验证成功后,客户端也连接成功了.服务端也能通过http://IP:8161登录到控制台. 但是在点击队列,想要查看队列视图时报错,如下图: 查看日志发 ...

  4. 关于ActiveMq的Exception occurred while processing this request, check the log for more information!问题

    错误原因:jsp渲染的时候报错了.根本原因在于jdk版本和activemq版本的问题. 两种解决方案: 1.把jdk版本改为jdk1.7 2.activeMQ采用5.15,它依赖于jdk1.8

  5. struts2与struts1整合,java.lang.InstantiationException, Exception occurred during processing request: null

    做了2个action,其中一个运行没有问题,另一个报错,看下面的报错信息,再看了看struts.xml,因为没有给GetBooks这个action配置actionform,所以就导致报null.下面是 ...

  6. SSH中使用延迟加载报错Exception occurred during processing request: could not initialize proxy - no Session

    17:40:17,249 ERROR DefaultDispatcherErrorHandler:42 - Exception occurred during processing request: ...

  7. Exception occurred during processing request: id to load is required for loading

    ERROR Dispatcher:38 - Exception occurred during processing request: id to load is required for loadi ...

  8. HTTP Status 500 - An exception occurred processing at line 35

    HTTP Status 500 - An exception occurred processing JSP page /manage/addCategory.jsp at line 35 type ...

  9. HTTP Status 500 - An exception occurred processing JSP page /WEB-INF

    HTTP Status 500 - An exception occurred processing JSP page /WEB-INF/test/showCountry.jsp at line 11 ...

随机推荐

  1. Struts2的模板和主题theme及自定义theme的使用

    Struts2的模板和主题theme及自定义theme 标签: struts2 2016-03-29 11:22 190人阅读 评论(0) 收藏 举报  分类: javaweb(8)  Struts2 ...

  2. http的六种请求方法

    1.get: GET可以说是最常见的了,它本质就是发送一个请求来取得服务器上的某一资源.资源通过一组HTTP头和呈现数据(如HTML文本,或者图片或者视频等)返回给客户端.GET请求中,永远不会包含呈 ...

  3. 浅谈T-SQL中的特殊联结

    引言 上一篇博客我们介绍了交叉联接,内联接,外联接3种基本的联接操作.这一篇文章我们介绍一些特殊的联接操作. 组合联接 组合联接就是联接条件涉及到联接两边的多个列的查询.当需要根据主键-外键关系来联接 ...

  4. Html.RenderPartial、Html.RenderAction联系与区别

    1.引言 开发人员经常希望应用程序可以在多个不同的地方使用同样的Razor标签和HTML标记代码.这并不需要我们在多个地方重复这些标签,使用MVC中的分部视图和子动作可以让我们很好的解决类似的情况. ...

  5. Thinkphp 整理备忘 杂记

    1:输出变量函数  (手册目录:控制器-输出变量) I('变量类型.变量名',['默认值'],['过滤方法'],['额外数据源']) 例:$title = I('post.title','','str ...

  6. java中InvocationHandler 用于实现代理。

    以下的内容部分参考了网络上的内容,在此对原作者表示感谢! Java中动态代理的实现,关键就是这两个东西:Proxy.InvocationHandler,下面从InvocationHandler接口中的 ...

  7. Oracle nvl(),nvl2()函数介绍

    NVL函数 Oracle/PLSQL中的一个函数. 格式为: NVL( string1, replace_with) 功能:如果string1为NULL,则NVL函数返回replace_with的值, ...

  8. iOS9新特性(1)-解决http请求失败的问题

    iOS9默认不支持HTTP请求,需要改用更安全的HTTPS(默认用TLS 1.2). 但事实上,有些地方用HTTP比HTTPS更适合,而且把服务端升级到TLS 1.2也不是一时半会能够搞定的.幸好苹果 ...

  9. virtualbox 中的linux 共享文件 发生文件系统类型错误的解决办法

    转自:http://blog.csdn.net/ls1160/article/details/24913391 最近在研究linux下的安卓源代码编译,遇到了一些问题,在虚拟机的共享文件上. 因为联网 ...

  10. 黄学长模拟day1 某种密码

    关于某种密码有如下描述:某种密码的原文A是由N个数字组成,而密文B是一个长度为N的01数串,原文和密文的关联在于一个钥匙码KEY.若KEY=∑▒[Ai*Bi],则密文就是原文的一组合法密码. 现在有原 ...