![](/img/trans.png)
[英]ServiceStack XDomainRequest and Missing Content-Type header
[英]Can we exclude setting http header Content-type:application/json from the request?
我正在尝试使用Chrome中的Postman插件创建邮递员收款请求。
请求的预览如下所示:
PUT /api/20130409/system/users/618a9ff389bc4bcda22e20150f818d78 HTTP/1.1
Host: 127.0.0.1:81
Content-Type: application/json
Cache-Control: no-cache
{ "User": { "UserName": "updated1", } }
然后,我从请求中删除了Content-Type
标头,并将ServiceStack的DefaultContentType
属性设置为“ application / json”。
ServiceStack是否应该将请求内容解释为JSON? (在我的盒子上失败)
我的理解是DefaultContentType
是关于在请求上设置“ Accept”标头的。 如果请求中没有为“ Accept”标头设置"Application/json"
或"Application/xml"
类的特定值,则响应内容将默认为在DefaultContentType
属性上设置的值。
如果我的上述理解是正确的...
在PUT/POST
方案中,请求是否总是需要设置适当的Content-Type
标头?
我不确定默认的内容类型,但是您可以在主机配置中修改和设置所需的内容类型,请尝试以下操作:
DefaultContentType = ContentType.Json
您也可以选择xml。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.