473,320 Members | 1,859 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,320 software developers and data experts.

defaultRedirect not working (ASP.Net 2.0)

I think I am missing something about how to redirect to a certain page when
404 errors occur. I want to redirect to a generic pagenotfound.aspx page. I
have the following in web.config:

<customErrors mode="RemoteOnly" defaultRedirect="/misc/pagenotfound.aspx">
</customErrors>

However, when I enter a non-existent URL I just get the default Page Not
Found error page - my pagenotfound.aspx file is not invoked (it works fine if
I enter the full URL of the http://www.mysite.com/misc/pagenotfound.aspx page
directly, so there is no issue with the page itself).

I have this working fine on an ASP.Net 1.1 site.

Any ideas on what I am doing wrong?

Thanks.
May 16 '07 #1
4 5992
Hi,
you can try by putting tilde(~) before URL:
<customErrors mode="RemoteOnly" defaultRedirect="~/misc/pagenotfound.aspx">
</customErrors>
The tilde (~) in front of URLs means that these URLs point to the root of
your web application.
Better still try with absolute URL instead of Relative URL:
<customErrors mode="RemoteOnly"
defaultRedirect="http://www.mysite.com/misc/pagenotfound.aspx ">
</customErrors>
For more details refer below link:
http://aspnetresources.com/articles/...rrorPages.aspx
--
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"Mark" wrote:
I think I am missing something about how to redirect to a certain page when
404 errors occur. I want to redirect to a generic pagenotfound.aspx page. I
have the following in web.config:

<customErrors mode="RemoteOnly" defaultRedirect="/misc/pagenotfound.aspx">
</customErrors>

However, when I enter a non-existent URL I just get the default Page Not
Found error page - my pagenotfound.aspx file is not invoked (it works fine if
I enter the full URL of the http://www.mysite.com/misc/pagenotfound.aspx page
directly, so there is no issue with the page itself).

I have this working fine on an ASP.Net 1.1 site.

Any ideas on what I am doing wrong?

Thanks.
May 16 '07 #2
Thanks for the response, Manish. No, no joy I am afraid. I still get the
default 404 page. Do you know if there is anyway to trace that at least an
attempt was made to redirect to my error page? My guess is that the
"plumbing" isn't in place for some reason and there is actually no attempt to
call my page. Any way to validate this. I am afraid I have been stuck on this
issue for a day or two.

Thanks again,

"Manish Bafna" wrote:
Hi,
you can try by putting tilde(~) before URL:
<customErrors mode="RemoteOnly" defaultRedirect="~/misc/pagenotfound.aspx">
</customErrors>
The tilde (~) in front of URLs means that these URLs point to the root of
your web application.
Better still try with absolute URL instead of Relative URL:
<customErrors mode="RemoteOnly"
defaultRedirect="http://www.mysite.com/misc/pagenotfound.aspx ">
</customErrors>
For more details refer below link:
http://aspnetresources.com/articles/...rrorPages.aspx
--
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"Mark" wrote:
I think I am missing something about how to redirect to a certain page when
404 errors occur. I want to redirect to a generic pagenotfound.aspx page. I
have the following in web.config:

<customErrors mode="RemoteOnly" defaultRedirect="/misc/pagenotfound.aspx">
</customErrors>

However, when I enter a non-existent URL I just get the default Page Not
Found error page - my pagenotfound.aspx file is not invoked (it works fine if
I enter the full URL of the http://www.mysite.com/misc/pagenotfound.aspx page
directly, so there is no issue with the page itself).

I have this working fine on an ASP.Net 1.1 site.

Any ideas on what I am doing wrong?

Thanks.
May 16 '07 #3
Hi,
Try with mode="On"
<customErrors mode="On" defaultRedirect="/misc/pagenotfound.aspx">
</customErrors>
Why that ugly page is displaying is that you are viewing page on your local
host and mode is set to "RemoteOnly".You need to set mode to "On".
Description of different modes are:
On
Specifies that custom errors are enabled. If no defaultRedirect attribute
is specified, users see a generic error. The custom errors are shown to the
remote clients and to the local host.

Off
Specifies that custom errors are disabled. The detailed ASP.NET errors are
shown to the remote clients and to the local host.

RemoteOnly
Specifies that custom errors are shown only to the remote clients, and that
ASP.NET errors are shown to the local host. This is the default value.

Hope this helps.
--
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"Mark" wrote:
I think I am missing something about how to redirect to a certain page when
404 errors occur. I want to redirect to a generic pagenotfound.aspx page. I
have the following in web.config:

<customErrors mode="RemoteOnly" defaultRedirect="/misc/pagenotfound.aspx">
</customErrors>

However, when I enter a non-existent URL I just get the default Page Not
Found error page - my pagenotfound.aspx file is not invoked (it works fine if
I enter the full URL of the http://www.mysite.com/misc/pagenotfound.aspx page
directly, so there is no issue with the page itself).

I have this working fine on an ASP.Net 1.1 site.

Any ideas on what I am doing wrong?

Thanks.
May 16 '07 #4
I am not sure that's it, Manish. Whether I do this locally or remotely I
still get exactly the same behavior. I wish I could prove this but I have a
strong guess that no attempt is being made to invoke my pagenotfound.aspx
file. If everything is OK (web.config is correct, the page exists, etc) then
no error message should be displayed, regardless of what mode is used
(because the redirect to my page should kick in whether I am local or
remote), right?

Thanks.
"Manish Bafna" wrote:
Hi,
Try with mode="On"
<customErrors mode="On" defaultRedirect="/misc/pagenotfound.aspx">
</customErrors>
Why that ugly page is displaying is that you are viewing page on your local
host and mode is set to "RemoteOnly".You need to set mode to "On".
Description of different modes are:
On
Specifies that custom errors are enabled. If no defaultRedirect attribute
is specified, users see a generic error. The custom errors are shown to the
remote clients and to the local host.

Off
Specifies that custom errors are disabled. The detailed ASP.NET errors are
shown to the remote clients and to the local host.

RemoteOnly
Specifies that custom errors are shown only to the remote clients, and that
ASP.NET errors are shown to the local host. This is the default value.

Hope this helps.
--
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"Mark" wrote:
I think I am missing something about how to redirect to a certain page when
404 errors occur. I want to redirect to a generic pagenotfound.aspx page. I
have the following in web.config:

<customErrors mode="RemoteOnly" defaultRedirect="/misc/pagenotfound.aspx">
</customErrors>

However, when I enter a non-existent URL I just get the default Page Not
Found error page - my pagenotfound.aspx file is not invoked (it works fine if
I enter the full URL of the http://www.mysite.com/misc/pagenotfound.aspx page
directly, so there is no issue with the page itself).

I have this working fine on an ASP.Net 1.1 site.

Any ideas on what I am doing wrong?

Thanks.
May 16 '07 #5

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

Similar topics

1
by: Darrin J Olson | last post by:
I am having trouble with the page redirecting for handling errors. I have the following in my Web.config file: <customErrors mode="On" defaultRedirect="Errs/AppError.aspx"> <error statusCode="404"...
1
by: Gary | last post by:
I have the following in my web.config.... <customErrors mode="RemoteOnly" defaultRedirect="Applicationerror.aspx"/> but, my error page does not display. Instead a 'Runtime Error' page...
6
by: Gary | last post by:
I have the following in my web.config.... <customErrors mode="RemoteOnly" defaultRedirect="Applicationerror.aspx"/> but, my error page does not display. Instead a 'Runtime Error' page...
21
by: Gary | last post by:
When using an ASPX page for a DefaultRedirect it does not work if the ASPX page has any code in it. If I put ... If Not IsPostBack Then lblMessage.Text = Server.GetLastError.Message End If ...
1
by: Dave | last post by:
Hi I want to know if it's possible to user Server.GetLastError() in my AppError.aspx below? The GetLastError is not available here and returns null. I'm using Application_Error event to send an...
0
by: Markus Rytterkull | last post by:
Hi I'm just testing some web stuff and created a errorpage to display nice messages to all users My page that raises the error uses Server.GetLatestError to get the error and store in a session...
5
by: tshad | last post by:
I have been working with setting my drop boxes to allow double clicking to select an item. It worked fine until I made some changes. I then stripped the page down to the bare essentials to find...
2
by: ad | last post by:
I have a customErrors section in Web.config. All error except error 403 and 404, will be redirect to GenericErrorPage.aspx. How can I show the e.Message or some explicit statement according...
1
by: Jonas | last post by:
Hi, I've got an ASP.NET application that I would like to use the defaultRedirect attribute of customErrors element to redirect to a custom aspx-page in case of errors. But the page just doesn't...
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
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)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.