我正在使用 ASP.Net MVC2 并为我的博客提供 RSS 提要。我在 System.ServiceModel.Syndication 和 Rss20FeedFormatter 中使用了开箱即用的功能。
提要工作正常,可以被 Outlook 以及我尝试过的每个浏览器读取。但是,当我将 RSS 提要作为站点地图提交给谷歌时,我收到了验证错误。
出于好奇,我使用报告了类似问题的 feedvalidator 验证了提要。
饲料: http: //www.chrispfarrell.com/Blog/Rss
如果你在 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 的代码,但它是非常标准的代码。
谢谢
克里斯·法瑞尔