Server.Transfer not working from Application_error for 404 events

J

jeff29_b

I am trying to remove dependence on the frameworks custom error
mechanisms to get a site to work with google sitemaps, because they
framework does a redirect 302 to the errorpage.

Instead I am doing server.transfers from the applicaiton_error event.
This seems to work fine except for in the case of 404 errors. Is there
any way to do a server.transfer from application_error on a 404 error?
 
B

Bruce Barker

a 404 is file not found. iis is returning this, not asp.net. you would need
an isapi filter, or asp.net module with all file extensions mapped to the
asp.net (unless you only need to catch 404 on *.aspx).

-- bruce (sqlwork.com)
 
J

jeff29_b

I have already handled the case using iis for the file extensions that
are not handled by asp.net. These pages are configured through iis.

I am looking at the specific case of .aspx files because those requests
are directed to asp.net whether or not the page exists. And in that
case I need to do a Server.Transfer in my application_error function so
that asp.net does not do a redirect ( 302 ) first. I have to do this
to comply with google sitemaps. Apparently, there is no way to do this
..net for a 404 error in the application_error function. I know there
is probably a work around by creating a module that checks for files.
I was hoping that someone found a way to make this work without
resorting to that.
 
G

Guest

If you only need to catch the 404 in .aspx, then why can't you set up a
custom 404 page in IIS that's an aspx page and handle it there?
Peter
 
J

jeff29_b

I am already doing that. BUT, for requests of .aspx extensions they
are not handled by iis. They are handled by the asp.net worker
process, so when a user or webcrawler requests foo.aspx it is routed to
the worker process whether it exists or not. Then mapHttpHandler
throws an exception. At this point iis is already out of the picture
so you have to either use asp.net's built in custom error facilities,
which don't work for my purpose because of the fact they do a redirect
or you have to do a server.transfer from application_error which
doesn't seem to be working because there is no context.

If there is some way to have iis handle a request for foo.aspx that
doesn't exist before or after the worker process handles it I am all
ears. Any suggestions?
 
G

Guest

I believe you can get IIS to handle the 404 on *.aspx via custom error page
settings by checking the "Check that file Exists" checkbox under your .aspx
ISAPI Mapping setting (IIS Site Properties - Home Configuration - ISAPI
Extensions - .aspx properties)
 

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

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top