Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用RSS SyndicationFeed api呈现pubDate_C#_Asp.net Mvc_Rss_Syndicationfeed - Fatal编程技术网

C# 使用RSS SyndicationFeed api呈现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

我正在尝试从我的ASP.NETMVC站点提供RSS提要。pubdate元素的一切都正常。我似乎无法让Rss20FeedFormatter输出它。我认为它映射到SyndicationFeed对象上的LastUpdateDate属性,但输出为LastBuildDate

有人知道我如何使用SyndicationFeed和Rss20FeedFormatter在我的RssFeed中呈现pubDate节点吗

   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"));

您只需注意正确设置日期格式,请查看此处:

谢谢,这正是我要找的。谢谢,这正是我要找的。