Redirecting to the default 404 page

N

Nobody

I am using C# ASPX and responding to the client with a page depending on
what is in the query string. If the location in the query string is not
found, I want to return the default 404 page. How do I output the DEFAULT
404 page? I know I can send manual headers, but I don't want that... I want
to return to the client what the web server would send if the ASPX was not
found. Also, I know I could redirect to an invalid location, but the
location bar would change for the client and I do not want that either.

Thanks
 
D

DalePres

Create a custom 404 handler in Web.config as follows:

<customErrors mode="On">
<error statusCode="404" redirect="My404ErrorPage.aspx" />
</customErrors>

Now all 404 errors go to My404ErrorPage.aspx (or whatever you choose to name
your error page) and you can also redirect to it at will.

Dale
 
N

Nobody

This is my point, I don't want a "custom handler"... In fact, it doesn't
matter if a handler is there or not. From a valid loaded page I simply want
to output the DEFAULT/CURRENTLY ACTIVE (whatever it may be, regardless of a
handler or not) 404 page. My ASPX doesn't care what 404 handler is in use,
I simply want to exercise it! If my ASPX page loads a query which it
doesn't understand, I want to output the 404 currently configured on the
server without having to do some dumb redirection. This really isnt a
difficult concept to grasp. Surely there is a way to say
"Response.WriteError(404);" and the webserver will handle the rest.
 

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,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top