If one omits the Accept header in a request to an Asp.Net web API the server will return (415) Unsupported Media Type
I am looking for a way to force the API to assume a default return type (in my case, application/json) when the request does not contain an Accept value in its headers.
After a substantial amount of reading and searching, I'm not sure this is even possible?
This is content negotiator resposibility to choose the right formatter to serialize the response object. But by default WebApi framework gets
JsonFormatterif could not find appropriate formatter.So it is strange behavior. Anyway you could set up custom content negotiator to choose explicit
JsonFormatterif request does not haveAcceptheader.And replace in
HttpConfigurationobject