C# 使用RSS SyndicationFeed api呈现pubDate
我正在尝试从我的ASP.NETMVC站点提供RSS提要。pubdate元素的一切都正常。我似乎无法让Rss20FeedFormatter输出它。我认为它映射到SyndicationFeed对象上的LastUpdateDate属性,但输出为LastBuildDate 有人知道我如何使用SyndicationFeed和Rss20FeedFormatter在我的RssFeed中呈现pubDate节点吗C# 使用RSS SyndicationFeed api呈现pubDate,c#,asp.net-mvc,rss,syndicationfeed,C#,Asp.net Mvc,Rss,Syndicationfeed,我正在尝试从我的ASP.NETMVC站点提供RSS提要。pubdate元素的一切都正常。我似乎无法让Rss20FeedFormatter输出它。我认为它映射到SyndicationFeed对象上的LastUpdateDate属性,但输出为LastBuildDate 有人知道我如何使用SyndicationFeed和Rss20FeedFormatter在我的RssFeed中呈现pubDate节点吗 public class RssActionResult : ActionResult
public class RssActionResult : ActionResult
{
public SyndicationFeed Feed { get; set; }
public override void ExecuteResult(ControllerContext context)
{
context.HttpContext.Response.ContentType = "application/rss+xml";
var rssFormatter = new Rss20FeedFormatter(Feed, false);
using (var writer = XmlWriter.Create(context.HttpContext.Response.Output, new XmlWriterSettings{ Indent = true}))
rssFormatter.WriteTo(writer);
}
}
我如何创建提要的示例
new SyndicationFeed("Title", "Description", url, "test_id", publishDate, feedItems){ LastUpdatedTime = publishDate}
对象模型目前似乎只支持项目上的pubDate,而不支持提要/频道上的pubDate。您可以将其添加为ElementExtension:
feed.ElementExtensions.Add("pubDate", "", DateTime.UtcNow.ToString("r"));
您只需注意正确设置日期格式,看看这里:对象模型目前似乎只支持项目上的pubDate,而不支持提要/频道上的pubDate。您可以将其添加为ElementExtension:
feed.ElementExtensions.Add("pubDate", "", DateTime.UtcNow.ToString("r"));
您只需注意正确设置日期格式,请查看此处:谢谢,这正是我要找的。谢谢,这正是我要找的。