返回ContentType "application/atom+xml"抛出错误



我正在创建一个模拟oData提要。真实的oData feed返回Content-Type: application/atom+xml;

我的ASP。. NET mock oData提要代码如下所示。DoClaimsRequest()返回字符串格式的JSON:

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

但是它生成一个错误,Internet Explorer"Feed format not supported","Internet Explorer does not support this Feed format"。

好吧,您说DoClaimsRequest()返回json字符串。仅仅因为声明了result.ContentType="application/atom+xml"并不意味着它将神奇地从json转换为atom。看看提琴手的反应…它可能是一个json字符串。IE被告知它将收到一个atom响应,但没有看到任何与该协议对应的内容。

最新更新