473,287 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Redirecting to the default 404 page

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
Nov 18 '05 #1
2 1548
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

"Nobody" <no****@nowhere.com> wrote in message
news:OX**************@TK2MSFTNGP10.phx.gbl...
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

Nov 18 '05 #2
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.
"DalePres" <don-t-spa-m-me@lea-ve-me-a-lone--.com> wrote in message
news:uL**************@TK2MSFTNGP10.phx.gbl...
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

"Nobody" <no****@nowhere.com> wrote in message
news:OX**************@TK2MSFTNGP10.phx.gbl...
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


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: jjjooooohhnnn | last post by:
Greetings, I have encountered what appears to be a fairly common problem: RedirectFromLoginPage is not redirecting to RedirectUrl. I have tried all the advice that I could on the 'net, and...
1
by: Jeremy Chapman | last post by:
I have built a web app. While testing I have found that if I browse to a page in the app, then get redirected to the login page and enter my credentials. The...
4
by: deepukutty | last post by:
HI all, I am using IE(Internet Explorer) as my default browser for asp.net application development. Today i faced a strange problem. When ever an exception occured in the page ....application...
41
by: amygdala | last post by:
Hello all, I have posted a similar question in comp.lang.php in the past, but haven't had any response to it then. I kinda swept the problem under the rug since then. But I would really like to...
9
by: Jonathan Wood | last post by:
I've spent days trying to come up with a solution. I'd appreciate it if anyone can help. My site requires all users to log on. There are three different roles of users, and each user type will...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.