ServiceStack XDomainRequest and Missing Content-Type header

124 Views Asked by At

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

1

There are 1 best solutions below

0
mythz On

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

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