Skip to Content
ASP.NET 3.5 For Dummies®
book

ASP.NET 3.5 For Dummies®

by Ken Cox
February 2008
Intermediate to advanced
428 pages
8h 52m
English
For Dummies
Content preview from ASP.NET 3.5 For Dummies®

9.2. Making an RSS Feed Available from Your Site

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:

  1. Add a generic handler named rsshandler.ashx to your project (FileNew FileGeneric HandlerAdd).

  2. Add the statement Imports System.Xml.Linq below Imports System.

  3. 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).

Figure 9-1. The RSS feed in Internet Explorer 7.
Listing 9-1. An RSS Feed Using LINQ to XML
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", ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET 3.5 Unleashed

ASP.NET 3.5 Unleashed

Stephen Walther
ASP.NET 4 Unleashed

ASP.NET 4 Unleashed

Stephen Walther, Kevin Hoffman, Nate Dudek

Publisher Resources

ISBN: 9780470195925Purchase book