Search code examples
c#asp.net-mvcodatacontent-type

Returning ContentType "application/atom+xml" throws error


I am creating a mock oData feed. The real oData feed returns Content-Type: application/atom+xml;.

My ASP.NET mock oData feed code looks like this. DoClaimsRequest() returns JSON in string format:

public ContentResult Service()
{
    ContentResult result = new ContentResult();
    result.Content = DoClaimsRequest();
    result.ContentType = "application/atom+xml";
    return result;
}

But it generates an error with Internet Explorer "Feed format not supported", "Internet Explorer does not support this feed format."


Solution

  • Well, you say that DoClaimsRequest() returns a json string. Just because you declare result.ContentType="application/atom+xml" does not mean it will be magically converted from json to atom. Have a look at the response in Fiddler...it is probably a json string. IE is told it will receive an atom response, but does not see any content that corresponds to that protocol.