調試一個使用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;)";
問題解決