1,注入IHttpContextAccessor httpContex

2,var req = _httpContext.HttpContext.Request;

  //  这句很重要,开启读取 否者下面设置读取为0会失败

  req.EnableBuffering();

  using (var reader = new StreamReader(_httpContext.HttpContext.Request.Body, Encoding.UTF8, true, 1024, true))
  {
    var a = await reader.ReadToEndAsync();
    id = JsonConvert.DeserializeObject<View>(a).Id;
  }

  // 这里读取过body  Position是读取过几次  而此操作优于控制器先行 控制器只会读取Position为零次的

  req.Body.Position = 0;

最新文章

  1. protocol buffers vs json vs XML
  2. hive 调优总结
  3. Default Title
  4. c++ 覆盖、重载与隐藏
  5. WinForm中DataGridView显示更新数据--人性版
  6. [原创]PCB知识补充
  7. BZOJ-2038 小Z的袜子(hose) 莫队算法
  8. android中正确导入第三方jar包
  9. King&#39;s Quest
  10. 基于GBT28181:SIP协议组件开发-----------第二篇SIP组件开发原理
  11. JavaScript学习笔记(一)对象和属性
  12. C#学习笔记-适配器模式
  13. windows10,redhat6.5下python3.5.2使用cx_Oracle链接oracle
  14. user-agent | what is the &quot;user-agent&quot; ?
  15. 依赖注入[7]: .NET Core DI框架[服务注册]
  16. 【原创】uC/OS 中LES BX,DWORD PTR DS:_OSTCBCur的作用及原理
  17. 在 delphiXE 10.2 上安装 FR5.4.6
  18. C# 操作符 &lt;&lt; 与 &gt;&gt;
  19. sql语句中having的作用是?
  20. [转]How to tell NLog to log exceptions?

热门文章

  1. Jquery Ztree异步加载树
  2. Docker详解(四) — Dockerfile剖析
  3. JAVA-JDBC-c3p0连接池配置
  4. IO复用,AIO,BIO,NIO,同步,异步,阻塞和非阻塞 区别
  5. SpringBoot系列:Spring Boot使用模板引擎FreeMarker
  6. KafkaStream-高级别API
  7. python入门之jieba库的使用
  8. Java学习笔记之方法
  9. Windows 批处理入门
  10. luogu P4035 [JSOI2008]球形空间产生器