【问题标题】:why does content-type header get removed?为什么内容类型标头会被删除?
【发布时间】:2018-02-14 11:01:22
【问题描述】:

我发出这样的请求:

当检查发送到我的控制器的内容时​​,似乎 Content-Type 标头甚至没有出现:

我做错了什么?为什么 Content-Type 标头被完全忽略?

【问题讨论】:

    标签: c# asp.net asp.net-web-api2 visual-studio-2017 postman


    【解决方案1】:

    这有点令人困惑,但 Content-Type 标头无法从通用“标头”集合中访问。

    您实际上应该从请求的内容对象上的 Headers 对象的 ContentType 属性中提取标头:

    var contentType = Request.Content.Headers.ContentType;
    

    【讨论】:

    • 如何将 contenttype 标头添加到新请求中?
    猜你喜欢
    • 2022-01-19
    • 1970-01-01
    • 2013-04-18
    • 1970-01-01
    • 2017-04-07
    • 1970-01-01
    • 2020-08-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多