Search code examples
asp.net-mvc-4asp.net-web-apiwxhttpx-http-method-override

XHTTP does not allow Accept header to specify JSON?


I'm hosting a mvc4 REST web api and I have a particular client that is using XHTTP (please don't ask why). However, it turns out that XHTTP is stripping off the "Accept" header and the client is trying to specify the request to come back as json. Unfortunately we dont' get the "Accept" header specified as json and instead return our default javascript format.

I was thinking about a potential workaround whereas they can specify &Accept=JSON in the query string but was wondering if anybody knows anything about XHTTP or how this could be resolved at the XHTTP end and my REST api end?

Thanks!


Solution

  • You could create a HttpMessageHandler that automatically sets the Accept header to application/json if none is provided.