473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

HTTPModule to generate RSS Feed

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
2 1503
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 43°2'17"N 88°2'37"W : 43°2'17"N 88°2'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
Thnk you but this doesn't exactly solve my problem. The formatted code was
intentional.
Aug 29 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Michael Iantosca | last post by:
I have a custom attribute that I attach to certain pages in my application and I want to inspect each page request as it is made to see if the custom attribute is attached to the underlying page...
0
by: Anonymous | last post by:
Hi, I would like to know a mechanism to generate a rss feed automatically. ( for example the rss feed should be created every day at 10:00am ) How can I achive this ? Can somebody tell me what...
7
by: nail | last post by:
Folks, I develop a HttpModule and it works correct, but one problem is occurs. After I register the httpmodule in the web.config, my pages (not testing http://localhost/site but...
7
by: Shapiro | last post by:
I have a scenario where I log a resquest to a database table and update the request with a corresponding response including the response time. I am using an HttpModule to do this. My challenge...
4
by: Danny W | last post by:
Hi There! Is it possible to use HttpModule to replace the built-in ASP.NET Session object? I want to write a HttpModule that will handle storing and retrieving of session values from an external...
2
by: Simon-Pierre Jarry | last post by:
Hi, I created a custom HttpModule for managing the security of my application. in "Init" sub, I regsiter the events doing that : Public Sub Init(ByVal context As System.Web.HttpApplication)...
2
by: walter | last post by:
Hi there, I know there is pool of HttpApplications, and for each request coming in, HttpRuntime will dedicate one from pool to serve the request. My questions are : 1. since HttpModule is plug...
4
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 with Apache 2.2. I'm looking for recommendations on free code I can use to generate RSS feeds. I found FeedCreator though Google, but that is terrible. It cannot...
3
by: Joseph Geretz | last post by:
I'm implementing a web application whose purpose in life is to act as a data conduit. Data is posted to my Web app in XML format, my application examines the data and forwards it onward by posting...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.