|
|
|
| Tuesday, September 01, 2009 |
FeedPage
Posted: 1:48:00 PM
|
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: ASP.Net RSS Toolkit, Coding, FeedPage, VB.NET
|
Fastest. Project. Evar.
Posted: 12:56:00 AM
|
I've decided that I'm going to write a website that combines my three main personal sites: Projects, roncli.com, and this blog.
One of the biggest features of this site is the ability to easily add an RSS feed to a webpage without having to write separate pages or nasty ASP.Net http handlers. Basically what I wanted was to have URL's that look like "...page.aspx" load the usual aspx, but "...page.aspx?feed=rss" load the RSS feed instead of the normal page.
This idea led me to the ASP.Net RSS Toolkit, a very easy to use toolkit with some nice features. Including the ability to quickly make RSS feeds. That, combined with a 34-line class (counting 6 blank lines) that inherits from System.Web.Ui.Page, overrides OnPreInit, and forces inheriting classes to override a GetFeed function, and I'm ready to create feeds not only in RSS, but also Atom, OPML, and RDF as well.
Wow. The demo app was more challenging to write than this gem.
I want to give it a test run, probably on some Six Minutes To Release pages, and see if it's stable. However, shortly thereafter I will probably release this to CodePlex so that other people can get their hands on it. I am rapidly becoming addicted to RSS feeds since my iPhone reads em pretty good using Byline. I have feeds from all over the Internet, and it's nice to be able to have one central place to find out what's going on in my own little corner of the world.Labels: ASP.Net RSS Toolkit, Blog, Byline, Coding, Gaming, Projects, roncli.com, Six Minutes To Release
|
|