开发者

Setting up my first RSS feed ever on ASP.NET page

I have never touched RSS feeds before.

What would I need to do in order to set my page up so that it can get a RSS feed onto the page?

I have a page that reads information from a database through a repeater control

<form id="form1" runat="server">
 <asp:Repeater ID="myRepeater" runat="server">
 <ItemTemplate>    
   <td width="330" align="left" valign="top"><p>
      <%#Eval("EventDetails")%></p> 
      <p><a href="<%#Eval("MoreInfoLink")%>" t开发者_运维百科arget="_blank">Register now</a></p>
  </td>
   <td width="150" align="left" valign="top"><p><asp:Image ID="Image1" ImageURL='<% #Eval("Logo") %>' runat="server" BorderWidth="0px" Width="90" Height="" /></p>

  </td>
</tr>

   

Is it possible to set up a RSS feed to this repeater control?


RSS Feeds are just basic XML documents.

Getting data from an RSS Feed is as simple as:

System.Xml.Linq.XDocument XD = System.Xml.Linq.XDocument.Load(Url);

System.Xml.Linq.XElement XE = XD.Element("rss").Element("channel");

Console.WriteLine("Title: " + XE.Element("title").Value);

Console.WriteLine("Description: " + XE.Element("description").Value);


RSS content is basically an XML file that you need to create, so, a short answer to your question would be NO.

What you can do, is to create an HTTPHandler that you would register in your application's web.config to be invoked when some RSS path is requested. Inside this handler, you can create the RSS XML and send it via the Response object.


I'd recommend against using repeaters to output an RSS feed directly, and instead use something like the RSS toolkit http://aspnetrsstoolkit.codeplex.com/

Once you've set up the RSS feed page, then you need to add:

<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feedurl">

To your page header and maybe a simple anchor link:

<a href="http://feedurl">RSS Feed</a>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜