Geo*_*ge2 1 .net c# asp.net rss visual-studio-2008
我正在使用VS2008 + C#+ .Net 3.5 + IIS 7.0 + ASP.Net来开发一个简单的Web应用程序.我想将RSS功能添加到我的网站的某些页面,以便人们可以使用他们流行的RSS阅读器来接收内容更新的通知.
在我的开发环境中执行此操作的任何简单方法?我只需要非常基本的RSS功能.
我建议你使用.NET 3.5附带的新Syndication API.以下是MSDN如何:创建基本RSS Feed文章的示例:
public class BlogService : IBlog
{
public Rss20FeedFormatter GetBlog()
{
SyndicationFeed feed = new SyndicationFeed("My Blog Feed", "This is a test feed", new Uri("http://SomeURI"));
feed.Authors.Add(new SyndicationPerson("someone@microsoft.com"));
feed.Categories.Add(new SyndicationCategory("How To Sample Code"));
feed.Description = new TextSyndicationContent("This is a how to sample that demonstrates how to expose a feed using RSS with WCF");
SyndicationItem item1 = new SyndicationItem(
"Item One",
"This is the content for item one",
new Uri("http://localhost/Content/One"),
"ItemOneID",
DateTime.Now);
SyndicationItem item2 = new SyndicationItem(
"Item Two",
"This is the content for item two",
new Uri("http://localhost/Content/Two"),
"ItemTwoID",
DateTime.Now);
SyndicationItem item3 = new SyndicationItem(
"Item Three",
"This is the content for item three",
new Uri("http://localhost/Content/three"),
"ItemThreeID",
DateTime.Now);
List<SyndicationItem> items = new List<SyndicationItem>();
items.Add(item1);
items.Add(item2);
items.Add(item3);
feed.Items = items;
return new Rss20FeedFormatter(feed);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1657 次 |
| 最近记录: |