[英]ServiceStack XDomainRequest and Missing Content-Type header
When I make a XDomainRequest on IE8/9 the Content-Type is not set, in fact Content-Type is missing from the HTTP Header. 当我在IE8 / 9上执行XDomainRequest时,未设置Content-Type,实际上HTTP标头中缺少Content-Type。 This is how IE XDomainRequest works.
这就是IE XDomainRequest的工作方式。
On the backend, how do I tell Servicestack to treat all incoming requests that do not have a Content - Type as application/Json 在后端,如何告诉Servicestack将所有没有Content-Type的传入请求视为application / Json
Thanks 谢谢
Jay 松鸦
You could add a PreRequestFilter in your AppHost that modifies the underlying Request ContentType for your Host, eg: 您可以在AppHost中添加PreRequestFilter,以修改主机的基础Request ContentType,例如:
this.PreRequestFilters.Add((req, res) =>
{
if (string.IsNullOrWhiteSpace(req.ContentType))
{
((AspNetRequest)req).HttpRequest.ContentType = MimeTypes.Json;
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.