Rss20FeedFormatter 生成的 RSS 格式不正确

发布于 2024-09-25 04:04:29 字数 1430 浏览 2 评论 0原文

我正在使用 ASP.Net MVC2,并且我的博客有一个 RSS 提要。我正在使用 System.ServiceModel.Syndicate 和 Rss20FeedFormatter 中的开箱即用功能。

该提要运行良好,可以由 Outlook 以及我尝试过的每个浏览器读取。然而,当我将 RSS feed 作为站点地图提交给 google 时,我遇到了验证错误。
出于好奇,我使用 feedvalidator 验证了 feed,该 feedvalidator 报告了类似的问题。

Feed:http://www.chrispfarrell.com/Blog/Rss

如果您弹出此 Feed在 feedvalidator.org 您会看到问题。

实际上没有自定义代码来生成 RSS。

控制器操作是

public FeedResult Rss()
        {
            const string baseUrl = "http://www.chrispfarrell.com/Blog/View/";

            var blogs = _blogService.GetBlogs();
            var feed = new SyndicationFeed
                           {
                               Title = new TextSyndicationContent("Chris Farrell"),
                               Copyright = new TextSyndicationContent("Copywrite Chris Farrell 2010")
                           };

            var postItems = blogs.Take(25)
                .Select(p => new SyndicationItem(p.Title,p.Body,new Uri(baseUrl + p.BlogUrl))
                                 {
                                     PublishDate = p.DateCreated,
                                 });

            feed.Items = postItems;
            return new FeedResult(new Rss20FeedFormatter(feed));
        }  

对于为什么提要无效且格式良好有任何评论吗?如果需要,我可以发布 FeedResult 的代码,但它是相当标准的代码。

谢谢克里斯

·法雷尔

I am using ASP.Net MVC2 and have a RSS feed for my blog. I am using out of the box functionality in System.ServiceModel.Syndication and Rss20FeedFormatter.

The feed works fine and can be read by Outlook as well as every browser I have tried. However when I submitted the RSS feed to google as a sitemap I got validation errors.
Out of curiosity I validated the feed with feedvalidator which reported similar issues.

Feed: http://www.chrispfarrell.com/Blog/Rss

If you pop this feed in at feedvalidator.org you will see the problems.

There is really no custom code going on to generate the RSS.

The controller action is

public FeedResult Rss()
        {
            const string baseUrl = "http://www.chrispfarrell.com/Blog/View/";

            var blogs = _blogService.GetBlogs();
            var feed = new SyndicationFeed
                           {
                               Title = new TextSyndicationContent("Chris Farrell"),
                               Copyright = new TextSyndicationContent("Copywrite Chris Farrell 2010")
                           };

            var postItems = blogs.Take(25)
                .Select(p => new SyndicationItem(p.Title,p.Body,new Uri(baseUrl + p.BlogUrl))
                                 {
                                     PublishDate = p.DateCreated,
                                 });

            feed.Items = postItems;
            return new FeedResult(new Rss20FeedFormatter(feed));
        }  

Any comments as to why the feed would not be valid and well formed? I can post the code for FeedResult if needed but its pretty standard code.

Thanks

Chris Farrell

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖树树初阳… 2024-10-02 04:04:29

该 Feed 缺少中的元素元素。

我现在使用的是接受 3 个参数(提要标题、描述和提要备用链接)的构造函数之一,而不是使用对象初始值设定项。提要备用链接的第三个参数在根通道中呈现。使提要现在有效的标签。

The Feed was missing the <link> element in the root <channel> element.

Rather than using an object initializer, I am using one of the constructors now which accepts 3 arguments(feed title, description and feed alternate link). The third argument for feed alternate link renders in the root channel <link> tag which makes the feed now valid.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文