By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,929 Members | 634 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,929 IT Pros & Developers. It's quick & easy.

HTTPModule to generate RSS Feed

P: n/a
I am writing a HTTP Module to generate an RSS feed for certain requests. For the moment everything is hardcoded and my code looks like (the idea is - for the moment to generate the RSS feed on the fly for every request - caching is another worry for later):
Public Class rssHTTPModule

Implements System.Web.IHttpModule

Public Sub Dispose() Implements System.Web.IHttpModule.Dispose

End Sub

Public Sub Init(ByVal Application As System.Web.HttpApplication) Implements System.Web.IHttpModule.Init

AddHandler Application.BeginRequest, AddressOf ApplicationBeginRequest

End Sub

Private Sub ApplicationBeginRequest(ByVal objSender As Object, ByVal e As System.EventArgs)

Dim app As HttpApplication = CType(objSender, HttpApplication)

Dim context As HttpContext = app.Context

Dim req As String = context.Request.Path

Dim localPath As String = context.Server.MapPath(req)

If Not (System.IO.File.Exists(localPath)) Then

If localPath.EndsWith("xml", StringComparison.InvariantCultureIgnoreCase) Then

Dim objStream As New System.Web.UI.HtmlTextWriter(context.Response.Outp ut)

objStream.WriteLine("<?xml version=""1.0"" encoding=""utf-8"" ?>")

objStream.AddAttribute("version", "2.0")

objStream.RenderBeginTag("rss")

objStream.RenderBeginTag("channel")

objStream.RenderBeginTag("title")

objStream.Write("test")

objStream.RenderEndTag()

objStream.RenderBeginTag("description")

objStream.Write("beschrijving")

objStream.RenderEndTag()

objStream.RenderBeginTag("language")

objStream.Write("en-us")

objStream.RenderEndTag()

objStream.RenderEndTag() ' channel

objStream.RenderEndTag() ' rss

objStream.Flush()

objStream.Close()

app.Response.StatusCode = 200

app.Response.StatusDescription = "OK"

app.CompleteRequest()

End If

End If

End Sub

End Class

What I want (to start with) is to be able to fire a request to my server www.myServer.com/jef.xml and make sure I generate the XML that has to be returned. Unfortunately, I am not able to do this. My current code is lacking something crucial. (If I execute my current code, IE explorer automatically opens a new favorite box and sharpreader just stops)

Aug 28 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
After trying to read this news article I realized you need to go to
http://www.stevemiller.net and get his free PureText tool which removes
formatting from text copied to the clipboard so it can be pasted as ASCII
text. Its a great tool that sits in the task tray.

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
MAP 432'17"N 882'37"W : 432'17"N 882'37"W
"Van den Driessche Willy" <wi*********************@gmail.comwrote in
message news:%2****************@TK2MSFTNGP03.phx.gbl...
I am writing a HTTP Module to generate an RSS feed for certain requests.
For the moment everything is hardcoded and my code looks like (the idea is -
for the moment to generate the RSS feed on the fly for every request -
caching is another worry for later):
Public Class rssHTTPModule
Implements System.Web.IHttpModule
Public Sub Dispose() Implements System.Web.IHttpModule.Dispose
End Sub
Public Sub Init(ByVal Application As System.Web.HttpApplication) Implements
System.Web.IHttpModule.Init
AddHandler Application.BeginRequest, AddressOf ApplicationBeginRequest
End Sub
Private Sub ApplicationBeginRequest(ByVal objSender As Object, ByVal e As
System.EventArgs)
Dim app As HttpApplication = CType(objSender, HttpApplication)
Dim context As HttpContext = app.Context
Dim req As String = context.Request.Path
Dim localPath As String = context.Server.MapPath(req)
If Not (System.IO.File.Exists(localPath)) Then
If localPath.EndsWith("xml", StringComparison.InvariantCultureIgnoreCase)
Then
Dim objStream As New System.Web.UI.HtmlTextWriter(context.Response.Outp ut)
objStream.WriteLine("<?xml version=""1.0"" encoding=""utf-8"" ?>")
objStream.AddAttribute("version", "2.0")
objStream.RenderBeginTag("rss")
objStream.RenderBeginTag("channel")
objStream.RenderBeginTag("title")
objStream.Write("test")
objStream.RenderEndTag()
objStream.RenderBeginTag("description")
objStream.Write("beschrijving")
objStream.RenderEndTag()
objStream.RenderBeginTag("language")
objStream.Write("en-us")
objStream.RenderEndTag()
objStream.RenderEndTag() ' channel
objStream.RenderEndTag() ' rss
objStream.Flush()
objStream.Close()
app.Response.StatusCode = 200
app.Response.StatusDescription = "OK"
app.CompleteRequest()
End If
End If
End Sub
End Class
What I want (to start with) is to be able to fire a request to my server
www.myServer.com/jef.xml and make sure I generate the XML that has to be
returned. Unfortunately, I am not able to do this. My current code is
lacking something crucial. (If I execute my current code, IE explorer
automatically opens a new favorite box and sharpreader just stops)
Aug 28 '06 #2

P: n/a
Thnk you but this doesn't exactly solve my problem. The formatted code was
intentional.
Aug 29 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.