关于 服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF 错误
用WebClient 去下载数据时发现有服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF错误,解决办法
1.在app.config种添加 web 在 web.config种添加
<system.net> <settings> <httpWebRequest useUnsafeHeaderParsing="true" /> </settings> </system.net>useUnsafeHeaderParsing的值【该方法须在发送请求之前进行设定否则无效果】public static bool SetAllowUnsafeHeaderParsing(bool useUnsafe)
{
//Get the assembly that contains the internal class
System.Reflection.Assembly aNetAssembly = System.Reflection.Assembly.GetAssembly(typeof(System.Net.Configuration.SettingsSection));
if (aNetAssembly != null)
{
//Use the assembly in order to get the internal type for the internal class
Type aSettingsType = aNetAssembly.GetType("System.Net.Configuration.SettingsSectionInternal");
if (aSettingsType != null)
{
//Use the internal static property to get an instance of the internal settings class.
//If the static instance isn't created allready the property will create it for us.
object anInstance = aSettingsType.InvokeMember("Section",
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.NonPublic, null, null, new object[] { }); if (anInstance != null)
{
//Locate the private bool field that tells the framework is unsafe header parsing should be allowed or not
System.Reflection.FieldInfo aUseUnsafeHeaderParsing = aSettingsType.GetField("useUnsafeHeaderParsing", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
if (aUseUnsafeHeaderParsing != null)
{
aUseUnsafeHeaderParsing.SetValue(anInstance, useUnsafe);
return true;
}
}
}
}
return false;
}
以上摘抄于http://www.cnblogs.com/lewisli/p/6775010.html
关于 服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF 错误的更多相关文章
- HttpWebRequest出错 服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF
服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF The server committed a protocol violation. Se ...
- WebRequest请求错误(服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF)
WebRequest请求错误(服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF)解决办法,天津config文件,增加一个配置如下 <?x ...
- 服务器提交了协议冲突. Section=ResponseHeader Detail=CR...的解决方案总结
今天在HttpWebRequest发送一个网页请求的时候,HttpWebResponse返回了一个奇怪的错误信息: 这个Http协议请求类可是微软封装的,我使用的流程可是中规中矩,不可能是我写错代码, ...
- c# winform 服务器提交了协议冲突. Section=ResponseStatusLine
[转] 最近在用.net写一个网络蜘蛛,发现对有的网站用HttpWebrequest抓取网页的时候会报错,捕获异常提示:"服务器提交了协议冲突 Section=ResponseStatusL ...
- httpwebrequest 服务器提交了协议冲突. section=responsestatusline
调用接口的时候,包: httpwebrequest 服务器提交了协议冲突. section=responsestatusline 解决方案: req.KeepAlive = false; req.Al ...
- 解决WebService/WCF调用时报错"服务器提交了协议冲突. Section=ResponseStatusLine"问题
今天更新了一个网站,新增了一个页面,调用WebService,在测试环境好好的,部署到正式环境后就莫名报错: 服务器提交了协议冲突. Section=ResponseStatusLine 网上查了好多 ...
- 关于“服务器提交了协议冲突. Section=ResponseStatusLine"问题
你的问题的原因是这样的,ASP.Net 2.0 增强了安全性,对一些有危害的http 头进行了判断,比如url中有空格的情况,以帮助网站提高网络攻击的防御能力.如果你的http头中有一些ASP.NET ...
- C#调取接口时报错:服务器提交了协议冲突. Section=ResponseStatusLine
private Dictionary<string, Object> GetLocation(string imei) { #region===代码=== string serviceAd ...
- 服务器提交了协议冲突。Section=ResponseHeader Detail=标头名称无效
服务器提交了协议冲突.Section=ResponseHeader Detail=CR 后面必须是LF. 微软没有容忍不符合RFC 822中的httpHeader必须以CRLF结束的规定的服务器响应所 ...
随机推荐
- easyui treegrid 动态展开数据(暂记)
ClassifyAdminSynMsgSvr.GetCLFLList("<%=CurUTag %>", 1, "", function (ret) ...
- Sql Server :SELECT a.*,b.HZXM FROM YG_LIS_JCBYTK a(nolock)中的NOLOCK作用
转自 http://blog.csdn.net/xingxing1828/article/details/34850771 先说下其区别,之后再做测试. 大家都知道,每新建一个查询,都相当于创建一个会 ...
- 快速排序javascript实现
快速排序基本思想: 以升序为例 数组arr,数组个数n; 1.选取一个待排序的元素.一般选第一个位置作为基准值temp=arr[0]. 2.选取带排序数组的两端元素的位置作为哨兵的位置,左端为哨兵i, ...
- day0319 模块
一.序列化 将原本的字典,列表等内容转化成一个字符串的过程就是序列化. 序列化的目的: 1.以某种存储形式使自定义对象持久化 2.将对象从一个地方传递到另一个地方. 3.程序更具有维护性 二. Jso ...
- CS231n: Convolutional Neural Networks for Visual Recognition
https://zhuanlan.zhihu.com/p/28522637 https://zhuanlan.zhihu.com/p/21930884 mark
- 转:eclipse maven build、maven install 等区别
原文地址:eclipse maven build.maven install 等区别
- nginx 负载均衡5种配置方式
nginx 负载均衡5种配置方式 1.轮询(默认) 每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器down掉,能自动剔除. 2.weight 指定轮询几率,weight和访问比率成正比, ...
- swift 字体自适应,宽高自适应
let kScreenWidth = UIScreen.main.bounds.width let kScreenHeight = UIScreen.main.bounds.height public ...
- 转: js实现全角半角检测的方法
//全角半角校验 function issbccase(strTmp) { for (var i=0; i<strTmp.length; i++) { if (strTmp.charCodeAt ...
- document.forms用法示例介绍
概述 forms 返回一个集合 (一个HTMLCollection对象),包含了了当前文档中的所有form元素. 语法 var collection = document.forms; documen ...