473,769 Members | 5,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.as px page. I
have the following in web.config:

<customErrors mode="RemoteOnl y" defaultRedirect ="/misc/pagenotfound.as px">
</customErrors>

However, when I enter a non-existent URL I just get the default Page Not
Found error page - my pagenotfound.as px 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 6013
Hi,
you can try by putting tilde(~) before URL:
<customErrors mode="RemoteOnl y" defaultRedirect ="~/misc/pagenotfound.as px">
</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="RemoteOnl y"
defaultRedirect ="http://www.mysite.com/misc/pagenotfound.as px ">
</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.as px page. I
have the following in web.config:

<customErrors mode="RemoteOnl y" defaultRedirect ="/misc/pagenotfound.as px">
</customErrors>

However, when I enter a non-existent URL I just get the default Page Not
Found error page - my pagenotfound.as px 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="RemoteOnl y" defaultRedirect ="~/misc/pagenotfound.as px">
</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="RemoteOnl y"
defaultRedirect ="http://www.mysite.com/misc/pagenotfound.as px ">
</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.as px page. I
have the following in web.config:

<customErrors mode="RemoteOnl y" defaultRedirect ="/misc/pagenotfound.as px">
</customErrors>

However, when I enter a non-existent URL I just get the default Page Not
Found error page - my pagenotfound.as px 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.as px">
</customErrors>
Why that ugly page is displaying is that you are viewing page on your local
host and mode is set to "RemoteOnly".Yo u 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.as px page. I
have the following in web.config:

<customErrors mode="RemoteOnl y" defaultRedirect ="/misc/pagenotfound.as px">
</customErrors>

However, when I enter a non-existent URL I just get the default Page Not
Found error page - my pagenotfound.as px 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.as px
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.as px">
</customErrors>
Why that ugly page is displaying is that you are viewing page on your local
host and mode is set to "RemoteOnly".Yo u 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.as px page. I
have the following in web.config:

<customErrors mode="RemoteOnl y" defaultRedirect ="/misc/pagenotfound.as px">
</customErrors>

However, when I enter a non-existent URL I just get the default Page Not
Found error page - my pagenotfound.as px 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
2114
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" redirect="Errs/NotFound.aspx"/> </customErrors> When I hit an error, it redirects me to the Errs/AppError.aspx page, and it shows the original page that generated the error as a parameter in the URL, but it doesn't show the contents of the...
1
1401
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 displays showing how to setup CustomErrors. I can't see anything wrong with the entry.
6
4138
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 displays showing how to setup CustomErrors. However, if I make my error page a .htm page it shows fine. Anyone know why?
21
2722
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 in the ASPX page it does not display when an unhandled exception is thrown.
1
2410
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 email, but I also want to create a custom error page in the AppError.aspx that displays some of the error message. Do I have to preserve the error message in the Application_Error event <customErrors mode="On" defaultRedirect="AppError.aspx"/> ...
0
1172
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 variable My web.config file has a customErrors-tag and uses defaultRedirect to redirect to my errors page It works fine, the error is caught on my page, session variable is set but on the errorpage the session is empty Why is a new session...
5
3064
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 out why it quit working. I found that if I didn't have a linkbutton, it quit working????????? If I changed the linkbutton to a regular button, it quit working. Here is the page:
2
4375
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 the error type in GenericErrorPage.aspx? ---------------------------------------------------------------------------- ----------------------------------------------------
1
2537
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 get called, instead the default ASP.NET error page is shown. I no Application_Error sub in global.asax.vb so the web.config should rule this. Any tips?
0
9583
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10039
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9860
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6668
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5297
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5445
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3560
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.