roncli.com blog
The blog of roncli
roncli.com blog
roncli.com
blog
Profile
roncli
Houston, Texas, United States
Labels
Coding
CTG Music
Editorials
Games
Miscellaneous
Music
Servers
Silliness
Software
Sports
Trax in Space Beta
Weather
Recent Posts
Fastest. Project. Evar.
LibWowArmory 0.2 beta
LibWowArmory coming along slowly
Yahoo! Pipes
Out With the Old and In With the New
LibBeImba 0.1.1 beta
Married Life
The last word
The Finished Product
Deja vu
Tuesday, September 01, 2009
FeedPage
Posted: 1:48:00 PM 0 comments
Because the code is so short, I've decided to just go ahead and post the code to FeedPage here. Remember, you must have a reference to the ASP.Net RSS Toolkit in order to compile this.

Imports RssToolkit.Rss
Imports System.Web.UI

Namespace roncliProductions.LibFeedPage

Public MustInherit Class FeedPage
    Inherits Page

    Protected Overrides Sub OnPreInit(ByVal e As System.EventArgs)
        MyBase.OnPreInit(e)
        Dim strFeed As String = Request.QueryString("feed")
        If Not String.IsNullOrEmpty(strFeed) Then
            If strFeed = "atom" Or strFeed = "opml" Or strFeed = "rdf" Or strFeed = "rss" Then
                Response.ContentType = "text/xml"
                Select Case strFeed
                    Case "atom"
                        Response.Write(GetFeed().ToXml(DocumentType.Atom))
                    Case "opml"
                        Response.Write(GetFeed().ToXml(DocumentType.Opml))
                    Case "rdf"
                        Response.Write(GetFeed().ToXml(DocumentType.Rdf))
                    Case "rss"
                        Response.Write(GetFeed().ToXml(DocumentType.Rss))
                End Select
            End If
            Response.End()
        End If
    End Sub

    Protected MustOverride Function GetFeed() As RssDocument

End Class

End Namespace


Easy enough. To use, simply change your inheritance from System.Web.UI.Page to roncliProductions.LibFeedPage.FeedPage, and inside that construct and return an RssDocument object. Then, when you add ?feed=xml to the URL of the page, you will get an RSS feed.

Labels: , , ,




0 Comments

Post a Comment