C#调取接口时报错:服务器提交了协议冲突. Section=ResponseStatusLine
private Dictionary<string, Object> GetLocation(string imei)
{
#region===代码===
string serviceAddress = string.Format("http://localhost/api/car/getlastinfo?imei={0}&key=xxxxx",imei);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(serviceAddress);
req.Method = "get";
req.KeepAlive = false;
var resp = new StreamReader(((HttpWebResponse)req.GetResponse()).GetResponseStream(), Encoding.GetEncoding("utf-8"));
string res = resp.ReadToEnd();
resp.Close();
Dictionary<string, Object> dic = null;
if (res != "")
{
dic = JsonConvert.DeserializeObject<Dictionary<string, Object>>(res);
}
return dic;
#endregion===代码===
}
解决:设置 req.KeepAlive = false;
C#调取接口时报错:服务器提交了协议冲突. Section=ResponseStatusLine的更多相关文章
- 解决WebService/WCF调用时报错"服务器提交了协议冲突. Section=ResponseStatusLine"问题
今天更新了一个网站,新增了一个页面,调用WebService,在测试环境好好的,部署到正式环境后就莫名报错: 服务器提交了协议冲突. Section=ResponseStatusLine 网上查了好多 ...
- httpwebrequest 服务器提交了协议冲突. section=responsestatusline
调用接口的时候,包: httpwebrequest 服务器提交了协议冲突. section=responsestatusline 解决方案: req.KeepAlive = false; req.Al ...
- c# winform 服务器提交了协议冲突. Section=ResponseStatusLine
[转] 最近在用.net写一个网络蜘蛛,发现对有的网站用HttpWebrequest抓取网页的时候会报错,捕获异常提示:"服务器提交了协议冲突 Section=ResponseStatusL ...
- 关于“服务器提交了协议冲突. Section=ResponseStatusLine"问题
你的问题的原因是这样的,ASP.Net 2.0 增强了安全性,对一些有危害的http 头进行了判断,比如url中有空格的情况,以帮助网站提高网络攻击的防御能力.如果你的http头中有一些ASP.NET ...
- HttpWebRequest出错 服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF
服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF The server committed a protocol violation. Se ...
- 关于 服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF 错误
用WebClient 去下载数据时发现有服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF错误,解决办法 1.在app.config种添加 we ...
- WebRequest请求错误(服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF)
WebRequest请求错误(服务器提交了协议冲突. Section=ResponseHeader Detail=CR 后面必须是 LF)解决办法,天津config文件,增加一个配置如下 <?x ...
- 服务器提交了协议冲突. Section=ResponseHeader Detail=CR...的解决方案总结
今天在HttpWebRequest发送一个网页请求的时候,HttpWebResponse返回了一个奇怪的错误信息: 这个Http协议请求类可是微软封装的,我使用的流程可是中规中矩,不可能是我写错代码, ...
- 服务器提交了协议冲突。Section=ResponseHeader Detail=标头名称无效
服务器提交了协议冲突.Section=ResponseHeader Detail=CR 后面必须是LF. 微软没有容忍不符合RFC 822中的httpHeader必须以CRLF结束的规定的服务器响应所 ...
随机推荐
- python 合并字典/拼接字典
针对于python 3.5以上版本: 最好的最快的最优雅的方法是: result_dict = {**dict_1, **dict_2} 例如:( dict 代表 dictionary,也就是字典) ...
- python 导入json模块的用法
json用于字符串,和 python数据类型间进行转换,json模块有四个功能,dumps,dump,loads,load. json 用法 json.dumps 将数据通过特殊的形式转换为所有程序语 ...
- redis关闭和启动
redis关闭 到redis节点目录下执行如下命令 redis-cli -p 端口号 shutdown redis启动 ./redis-server 参数 参数:redis.conf文件全路径 需要到 ...
- [转载]企业级应用架构(NHibernater+Spring.Net+MVC3)
本人已经从事公司两套这类架构系统的开发工作啦!对于这套架构,我惊叹不已!BPS和CMS系统都是采用这套架构.但本人也同时渐渐发现了这套架构有诸多 不足之处,于是本人利用闲暇时光进一步改进了这套架构.新 ...
- express 设置允许跨域访问
//demo const express = require('express'); const app = express(); //设置允许跨域访问该服务. app.all(’’, functio ...
- java.lang.NoClassDefFoundError: javax/transaction/Synchronization
转自:https://blog.csdn.net/andsionok/article/details/68490848 今天在整合ssh框架中 程序报告Java.lang.NoClassDefFoun ...
- Manjaro美化 配置教程
Manjaro Linux的美化 切换源 sudo vi /etc/pacman.conf 加入arch源 [archlinuxcn] SigLevel = Optional TrustedOnly ...
- 基于 Ansible 的 ELK 部署说明
ELK-Ansible使用手册 ELK-Ansible 是基于 Ansible 的 Playbooks 研发的 ELK集群部署工具.本文将介绍如何使用 ELK-Ansible 快速部署 ELK 集群. ...
- flask之环境的搭建
一.查看ubantu上是否安装虚拟环境的包 virtualenv --version 这里显示的是:15.0.1的版本,如果没有的话, sudo pip install virtualenv sudo ...
- 项目中dubbo的标准配置
# Spring boot applicationspring: application: name: hello-dubbo-service-user-provider # UserService ...