« 沪"居住证转户籍"细则公布 审核通过人员信息将公示央视新闻联播揭露谷歌中国存在大量淫秽色情信息 »

c# 基础连接已经关闭: 连接被意外关闭,错误的解决

密陀僧发布 技术 2009年6月18日 次浏览
调试一个使用HttpWebRequest模拟提交表单的程序的时候频繁出现上述错误提示,google了一下发现了几个解决方案。
1、在application.config或web.config文件里加入

<system.net> 
<settings> 
<httpWebRequest useUnsafeHeaderParsing="true"/> 
</settings> 
</system.net> 


2、设置clientConnectionLimit属性需要在客户端的 .config 文件当中:
如:

<system.runtime.remoting> 
<application> 
<channels> 
<channel ref="http" clientConnectionLimit="50"> 
<clientProviders> 
<formatter ref="soap" /> 
</clientProviders> 
</channel> 
</channels> 
</application> 
</system.runtime.remoting> 


这两种方法都没能解决我的问题,突然看到有人提到headers信息的问题,增加一句代码

MyRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)";

问题解决。
转载请注明:转载自漱风斋[ http://0e2.net/ ]

本文链接地址:http://0e2.net/post/1173.html

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

Copyright 2009-3000 0e2.net. Some Rights Reserved.  Powered By Z-Blog.