我在 ASP.NET MVC 中看到了一些 RSS 提要的例子,比如 this ,以及项目中的一些示例(如 Oxite),但它们都不完整。
例如。他们都不检查标题
If-Modified-Since
在请求中,节省带宽。
我不想重新发明轮子,所以我在这里停下来问路。
最佳答案
我还没有看到它实现 HTTP_IF_MODIFIED_SINCE,但我会考虑使用 SyndicationFeed 类。它使处理提要变得非常简单,无需任何解析。我目前将它用于 Atom 提要,但它应该也适用于 RSS:
function SyndicationFeed GetFeed(string url) {
XmlReader reader = XmlReader.Create(url);
SyndicationFeed feed = SyndicationFeed.Load(reader);
return feed;
}
public ActionResult ShowFeed()
{
string feedUrl = "somefeedurl";
SyndicationFeed feed = GetFeed(feedUrl);
return View(feed);
}
...然后在 View 中:
<%foreach (var item in ViewData.Model.Items) { %>
<li><a href="<%=item.Id %>"><%=item.Title.Text %></a></li>
<% } %>
关于asp.net-mvc - 在 ASP.net MVC 中良好且完整地实现 RSS 提要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/369794/