使用WebClient进行数据采集(Internet上的aspx页),是WinForm程序,经常会遇到这样的异常:服务器提交协议冲突 Section=ResponseStatusLine网上有说法是CLR,于是我在WebClient请求之前加上了这个,但无效
webClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");求正解

解决方案 »

  1.   

    通过修改配置文件解决:在app.config文件里修改
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <system.net> 
            <settings> 
                <httpWebRequest  useUnsafeHeaderParsing= "true "  /> 
            </settings> 
        </system.net>
    </configuration>
    webClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;MyIE2; Alexa Toolbar; mxie; .NET CLR 1.1.4322"); 
      

  2.   

    我的是WinForm程序啊,目标站点我哪改得了啊
      

  3.   

    没人知道么,我这问题google、baidu了一个下午,还是没有找到正解