Creating rss with .xml extension

L

lee atkinson

Hi

I usually use a .ashx file to generate rss feeds using the xml writer method
however clients sometimes insist on have a .xml extension for the url , how
do you accomplish this with out messing around with IIS or having a static
..xml file sitting on the server that is updated periodically?

Cheers
Lee
 
H

Hans Kesting

lee atkinson explained on 19-2-2009 :
Hi

I usually use a .ashx file to generate rss feeds using the xml writer method
however clients sometimes insist on have a .xml extension for the url , how
do you accomplish this with out messing around with IIS or having a static
.xml file sitting on the server that is updated periodically?

Cheers
Lee

Just a guess: would this work as URL:
http://www.mysite.com/MyRssFeed.ashx/rss.xml

No change needed in your code, just in the published URL.

Hans Kesting
 
L

lee atkinson

That would look for a xml file in a directory called myrssfeed.ashx surely?
s
There must be an easy answer to this as I don't see many xml rss feeds that
arent called .xml or .rss

All I can think of is that an xml file is remapped to be parsed as dot net
on the server which I want to avoid

Lee
 
H

Hans Kesting

lee atkinson used his keyboard to write :
That would look for a xml file in a directory called myrssfeed.ashx surely?
s
There must be an easy answer to this as I don't see many xml rss feeds that
arent called .xml or .rss

All I can think of is that an xml file is remapped to be parsed as dot net
on the server which I want to avoid

Lee

No, it would still execute MyRssFeed.ashx, but with a "PathInfo" of
"rss.xml" (which you can choose to ignore)

Hans Kesting
 
C

Cowboy \(Gregory A. Beamer\)

One workaround is to publish the RSS file. You can make this part of your
save routine, when you save a new blog entry (assuming this is a blog). That
is a very common way of updating RSS.

Another would be to create an HTTP handler that offloaded the work for
feed.rss or feed.xml (specific name is your choice) to the ASHX file. To the
client, it would appear they are hitting an XML file, evne though they are
still hitting the same ASHX file.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

*********************************************
| Think outside the box |
*********************************************
 
M

miher

Hi,

I see You already got a clever solution, however i thought it might be
useful to mention the url mapping feature of asp.net.
(for example into web.config, under system.web put :
<urlMappings enabled="true">
<add mappedUrl="feed.ashx" url="~/feed.xml"/>
</urlMappings>
)

Hope You find this useful.
-Zsolt
 
L

lee atkinson

Hi Z , thanks for the response ... The urlmappings method would work great
but xml files don't seem to be supported for some reason , its remaps .aspx
and other files great - don't seem to work for xml files

This is what I tried -

<urlMappings enabled="true">
<add mappedUrl="~/feeds/rss/default.ashx" url="~/feed.xml"/>
</urlMappings>


Weird huh?
L
 
M

miher

Hi,

What do You mean by "don't seem to be supported" ? Please describe what is
not working, maybe we can figure out how to solve it.

-Zsolt
 
L

lee atkinson

I mean it displays the blank (unmapped) feed.xml file, and not the
default.ashx.

I tried the process with 'feed.aspx' and remaps fine .. So was assuming
theres an issue with .xml files ?

L
 
A

Andy B.

When I was reading up on httpHandlers (since I wanted to run rss feeds
through them as well), I found that for custom/unknown file extensions that
you want to create or to have asp.net handle known but unsupported filetypes
like xml, you have to register the mapping with IIS itself. The only way to
do that is to have control of the iis server config interface or have
someone at the web hosting service do it for you. After that it is just
registering it in the web.config file. So if you can't do either with IIS,
looks like we are both out of luck.
 
Joined
Mar 8, 2011
Messages
1
Reaction score
0
Try adding this to your web.config <handlers> section. It will recognise rss.xml files and redirect them.



<add name="RSS-XML" path="rss.xml" verb="*" type="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" preCondition="integratedMode" />

Use it along with:

<urlMappings enabled="true">
<add url="~/rss.xml" mappedUrl="~/rss.ashx" />
</urlMappings>

Ian Brown
http://www.ian-b.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top