Redirecting to the default 404 page

  • Thread starter Thread starter Nobody
  • Start date Start date
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
 
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
 
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.
 
Back
Top