简体   繁体   中英

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. This is how IE XDomainRequest works.

On the backend, how do I tell Servicestack to treat all incoming requests that do not have a Content - Type as application/Json

Thanks

Jay

You could add a PreRequestFilter in your AppHost that modifies the underlying Request ContentType for your Host, eg:

this.PreRequestFilters.Add((req, res) =>
{
    if (string.IsNullOrWhiteSpace(req.ContentType))
    {
        ((AspNetRequest)req).HttpRequest.ContentType = MimeTypes.Json;
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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