以下有两种方式可以获取响应的数据流

1. 接收端通过Request.InputStream读取流
public static string StreamRead()
{
byte[] byts = new byte[HttpContext.Current.Request.InputStream.Length];
HttpContext.Current.Request.InputStream.Read(byts, 0, byts.Length);
string req = System.Text.Encoding.UTF8.GetString(byts);
return HttpContext.Current.Server.UrlDecode(req);
}

2.
/// <summary>
/// 获得请求报文转换成字符串
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public static string getRequestBody(HttpRequestBase request)
{
string result = "";
using (Stream st = request.InputStream)
{
StreamReader sr = new StreamReader(st, Encoding.UTF8);
result = sr.ReadToEnd();
}
return result;
}

接收端通过Request.InputStream读取流的更多相关文章

  1. C# Request.InputStream 读取输入流为空的原因处理

    今天在手机App测试接口的时候发现一个通过POST方式的接口 获取body中的参数一直为空,但是在数据量小的时候却可以获取到数据,开始怀疑是不是POST的长度有限制,然后在web.config中修改了 ...

  2. ASP.NET中将数据作为XML数据发送 使用 Request.InputStream 接收

    将数据作为XML数据发送,例如:public void PostXml(string url, string xml){byte[] bytes = Encoding.UTF8.GetBytes(xm ...

  3. ASP.NET Core Action 读取流

    以前mvc5 action可以直接使用 var stream = HttpContext.Current.Request.InputStream; 读取流,在Core中有所不同,可以使用以下方式读取 ...

  4. file 从InputStream读取byte[]示例

    file 从InputStream读取byte[]示例 分类专栏: java基础   public static byte[] getStreamBytes(InputStream is) throw ...

  5. Java InputStream读取网络响应Response数据的方法

    Java InputStream读取数据问题 原理讲解 1. 关于InputStream.read()     在从数据流里读取数据时,为图简单,经常用InputStream.read()方法.这个方 ...

  6. 分享非常有用的Java程序(关键代码)(八)---Java InputStream读取网络响应Response数据的方法!(重要)

    原文:分享非常有用的Java程序(关键代码)(八)---Java InputStream读取网络响应Response数据的方法!(重要) Java InputStream读取数据问题 ======== ...

  7. InputStream 读取中文乱码 扩展

    对于InputStream读取中文乱码,下面这段话给出了很好的解释,以及后续编码上的扩展. BufferedInputStream和BufferedOutputStream是过滤流,需要使用已存在的节 ...

  8. 将一个读取流转换成bitmap对象

     将一个读取流转换成bitmap对象:         BitmapFactory:可以将文件,读取流,字节数组转换成一个Bitmap对象.         Bitmap bitmap = Bitma ...

  9. Request.InputStream 接收Post Data

    今天 用 Request.Form /Request.Params 等怎么也获取不到客户发过来的Post 数据 后来试着用了 Request.InputStream 竟然可以 using (Syste ...

随机推荐

  1. 阶段5 3.微服务项目【学成在线】_day02 CMS前端开发_23-CMS前端页面查询开发-分页查询实现

    修改为默认的参数 点击分页的事件 current-change 我们弹个alert测试下 看文档,参数是当前页 把当前页的数据赋值给params.page这个对象 分页效果实现 最终代码 <te ...

  2. anconda + python 3.6安装(以前的anconda,anaconda和python版本对应关系)

    anconda + python 3.6安装 anaconda + python3.6安装安装老版本带python3.6的anaconda安装老版本带python3.6的anacondaanacond ...

  3. Reset Password 重置密码 (CentOS 5,6,7 ; Juniper Networks: SRX100 )

    一些重置root 密码的文档分享(来自官网): CentOS 5,6,7 Juniper Networks :  SRX100 链接:https://share.weiyun.com/5BM4kwK ...

  4. Pytorch Tensor, Variable, 自动求导

    2018.4.25,Facebook 推出了 PyTorch 0.4.0 版本,在该版本及之后的版本中,torch.autograd.Variable 和 torch.Tensor 同属一类.更确切地 ...

  5. redis 获取方式和安装(windows)

    Windows redis :https://github.com/MSOpenTech/redis/releases Linux redis :https://github.com/phpredis ...

  6. Springboot 使用Jwt token失效时接口无响应(乌龙)

    问题背景:新项目使用Springboot框架,鉴权使用了Jwt 处理cors: @Configuration public class WebMvcConfig implements WebMvcCo ...

  7. PDF转任意格式 & 做动画效果

    1.PDF转任意格式 & 做动画效果|让PPT傻眼去吧! http://www.aiweibang.com/yuedu/6984803.html

  8. React—组件生命周期详解

    React—组件生命周期详解 转自 明明的博客  http://blog.csdn.net/slandove/article/details/50748473 (非原创) 版权声明:转载请注明出处,欢 ...

  9. SQL SERVER CONVERT函数

    定义: CONVERT函数返回 转换了数据类型的数据. 语法: CONVERT(target_type,expression,date_style smallint) 参数: ①target_type ...

  10. mysql 连接远程连接服务器 1130错误

    今天在用sqlyog连接非本地的Mysql服务器的数据库,居然无法连接很奇怪,报1130错误, ERROR 1130: Host 192.168.3.100 is not allowed to con ...