HttpHandler Question

  • Thread starter Thread starter digitalcolony
  • Start date Start date
D

digitalcolony

I had the .XML extension mapped to the ASP.NET DLL. And then I
updated the web.config as such.


And it works!

However, if the browser makes a request for any other XML file, it
fails. My guess is the ASP.NET DLL can't render .XML files. Is there
anyway to get XML files on the server to render if that extension is
mapped to the ASP.NET DLL?

thanks - MAS
 
re:
!> Is there anyway to get XML files on the server to render
!> if that extension is mapped to the ASP.NET DLL?

Have you considered using an .xsl file, instead of mapping XML files to the ASP.NET dll ?



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
I was building a sitemap.xml file for Google. I suppose I could use
another extension, but I was interested if there was a way to have a
HTTPHandler process one file and then have ASP.NET DLL dish up the XML
files on the file server as if it were IIS (correctly).

Possible?

MAS
 
re:
!> I was building a sitemap.xml file for Google.
!> I suppose I could use another extension

Maybe I wasn't clear enough...or I don't understand your question well enough.

If you write a sitemap.xsl file for sitemap.xml, and link to sitemap.xml, it will be rendered
automatically, without the need to map the XML extension to the aspnet_isapi dll.

Of course if, in spite of that, you still want to find a way to do that rendering by
mapping XML files to the aspnet_isapi dll, you are perfectly free to pursue that.

If you *only* want to build a sitemap.xml file for Google, you don't have to render it.
Google can read it without needing it to be rendered.




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
I was building a sitemap.xml file for Google. I suppose I could use
another extension, but I was interested if there was a way to have a
HTTPHandler process one file and then have ASP.NET DLL dish up the XML
files on the file server as if it were IIS (correctly).

Possible?

MAS
 
The purpose of the handler is to have C# generate a real-time dynamic
XML file.

Just to be clear, the Handler works. What doesn't work is the ability
to see other XML files, even though the HTTP Handler only intercepts
the request for sitemap.xml.

MAS
 
re:
!> Just to be clear, the Handler works. What doesn't work is the ability
!> to see other XML files, even though the HTTP Handler only intercepts
!> the request for sitemap.xml.

What happens if you map a wildcard ?

<add verb="*" path="*.xml" type="HttpExtensions.SitemapHandler"/>



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
The purpose of the handler is to have C# generate a real-time dynamic
XML file.

Just to be clear, the Handler works. What doesn't work is the ability
to see other XML files, even though the HTTP Handler only intercepts
the request for sitemap.xml.

MAS
 
Every XML request would go to the HTTP Handler code, which I don't
want.

The XML for the sitemap is generated by me.
The XML for the blog is generated by a 3rd party tool.

So I only want the HTTP Handler to process the sitemap request.

If I can just get the ASP.NET DLL to kick the additional XML requests
back to the browser without generating an error that would be ideal.
However, whereas IIS can render XML requests to the browser fine, the
ASP.NET DLL can't.

MAS
 
If you'll excuse a light-hearted moment, what you seek reminds me of :

"To dream the impossible dream
To fight the unbeatable foe
To bear with unbearable sorrow
To run where the brave dare not go..."

:-)



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
Every XML request would go to the HTTP Handler code, which I don't
want.

The XML for the sitemap is generated by me.
The XML for the blog is generated by a 3rd party tool.

So I only want the HTTP Handler to process the sitemap request.

If I can just get the ASP.NET DLL to kick the additional XML requests
back to the browser without generating an error that would be ideal.
However, whereas IIS can render XML requests to the browser fine, the
ASP.NET DLL can't.

MAS
 
Love the ELVIS reference.

My final solution was to create a 2nd HTTP Handler that catches all
other XML requests and streams them back to the browser as "text/xml".


MAS
 
try:

<httpHandlers>
<add verb="*" path="sitemap.xml" type="HttpExtensions.SitemapHandler"/>
<add verb="*" path="*.xml" type="HSystem.Web.DefaultHttpHandler"/>

-- bruce (sqlwork.com)
 
That was it Bruce!

An extra H was in your answer, but I figured it out.

<add verb="*" path="*.xml" type="System.Web.DefaultHttpHandler"/>

thanks!!!
MAS
 
I spoke too soon. That works inside Visual Studio 2005, but not via
IIS, since the default HTTP HAndler has now been remapped.

I ended up writing my own catch all.

MAS
 
Back
Top