繁体   English   中英

ServiceStack XDomainRequest和缺少Content-Type标头

[英]ServiceStack XDomainRequest and Missing Content-Type header

当我在IE8 / 9上执行XDomainRequest时,未设置Content-Type,实际上HTTP标头中缺少Content-Type。 这就是IE XDomainRequest的工作方式。

在后端,如何告诉Servicestack将所有没有Content-Type的传入请求视为application / Json

谢谢

松鸦

您可以在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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM