February 2008
Intermediate to advanced
428 pages
8h 52m
English
You can create an RSS feed by sending any list of data as an XML stream. The LINQ to XML capabilities in ASP.NET 3.5 make generating XML on the fly easy. Follow these steps to create an ASP.NET handler that produces an RSS feed:
Add a generic handler named rsshandler.ashx to your project (File
New File
Generic Handler
Add).
Add the statement Imports System.Xml.Linq below Imports System.
Replace the existing ProcessRequest() subroutine with the contents of Listing 9-1.
When you browse to rsshandler.ashx with Internet Explorer 7, the browser recognizes that it's RSS. IE 7 formats the content and makes it easy to subscribe to the feed (see Figure 9-1).
Public Sub ProcessRequest _
(ByVal context As HttpContext) _
Implements IHttpHandler.ProcessRequest
Dim rssdoc As New XDocument(New XDeclaration("1.0", Nothing, Nothing)) →4
rssdoc.Add(New XComment("XML to LINQ Generated RSS Feed")) →5 Dim rssrootelement As New XElement("rss", New XAttribute("version", ... |