为ASP.NETWebAPI生成Atom feed [英] Atom feed generate for ASP.NETWebAPI

查看:63
本文介绍了为ASP.NETWebAPI生成Atom feed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我需要使用webapi生成Atom,我尝试但总是将原子显示为json文本,我的标准原子阅读器是不读取该消息,任何人都可以建议实现此功能的方法,


预先谢谢,


Vijay

解决方案

嗨aluvala vijay,


您可以强制响应始终为atom + xml 使用"application / atom + xml"如下所示,你可以选择其中一个。

 public HttpResponseMessage GetFeed()
{
return Request.CreateResponse(HttpStatusCode.OK,feedInstance) ,"application / atom + xml");
}


public HttpResponseMessage GetFeed()
{
返回Request.CreateResponse(HttpStatusCode.OK,feedInstance,feedFormatter," application / atom + XML");
}


祝你好运,


章龙


Hi All,

i have a requirement to generate the Atom using the webapi, i try but always it is showing the atom as json text and my standard atom reader is not reading that message, can any one suggest an approach to achieve this functionality, 

Advance thanks,

Vijay

解决方案

Hi aluvala vijay,

You could force the response to always be atom+xml  with "application/atom+xml" like below, you could chose one of them.

public HttpResponseMessage GetFeed()
{
    return Request.CreateResponse(HttpStatusCode.OK, feedInstance, "application/atom+xml");
}


 public HttpResponseMessage GetFeed()
 {
    return Request.CreateResponse(HttpStatusCode.OK, feedInstance, feedFormatter, "application/atom+xml");
 }

Best regards,

Zhanglong


这篇关于为ASP.NETWebAPI生成Atom feed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆