473,769 Members | 6,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DefaultRedirect wont work for aspx pages

I have the following in my web.config....

<customErrors mode="RemoteOnl y" defaultRedirect ="Applicationer ror.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?
thanks,
G
Nov 18 '05 #1
6 4138
Hi Richard,
Thanks for posting in the community! My name is Steven, and I'll be
assisting you on this issue.
From your description, you've generated an custom error page(an aspx page)
to provide a friendly error display UI when some unhandlered exceptions
occur. However you found the "defaultRedirec t" custom error page you set
in the web.config file didn't work, you still got a runtime error instead
of the correct error page, yes?
If there is anything I misunderstood, please feel free to let me know.
First , I'd like to ask for some further infos on this issue:
1. Do you visit the certain page from a remote client or local client.
Since the "RemoteOnly " option will redirect only remote user to the custom
error page. Also, I may try set it as "On" to see whether it works.

2. Check on your custom error page( the aspx page) to see whether it is
correct at all? Also, you may try using a very simple aspx page to test
whether the problem is on the error page.

3. Do you have any other particular configuration setting for the certain
web application, such as formAthenticati on for page protection(fold er
protection). As for this point, you can try creating a new simple web
application and try using a custom error page to see whether the problem
remains.

Please check out the above steps and it would quite helpful if you could
provide me some more infos so as for me to repro the problem on my side.
Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #2
Steven,
Thanks for your reply. (BTW my name is Gary, not Richard :)

I have narrowed it down. It will work on an aspx page that has no code in
the codeBehind vb file. But, if I put..

If Not IsPostBack Then
lblMessage.Text = Server.GetLastE rror.Message
End If

in the Page_Load event then it does not work. The reason I wanted to use an
aspx page in the first place was because I wanted to at least inform the
user of the message so that they could report the problem. Using just an
..htm page robs the user of all information. Is there anyway to get it to
work with some code in the page? Why does it not work with code in the
page?
Thanks,
Gary


"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:mw******** ******@cpmsftng xa07.phx.gbl...
Hi Richard,
Thanks for posting in the community! My name is Steven, and I'll be
assisting you on this issue.
From your description, you've generated an custom error page(an aspx page)
to provide a friendly error display UI when some unhandlered exceptions
occur. However you found the "defaultRedirec t" custom error page you set
in the web.config file didn't work, you still got a runtime error instead
of the correct error page, yes?
If there is anything I misunderstood, please feel free to let me know.
First , I'd like to ask for some further infos on this issue:
1. Do you visit the certain page from a remote client or local client.
Since the "RemoteOnly " option will redirect only remote user to the custom
error page. Also, I may try set it as "On" to see whether it works.

2. Check on your custom error page( the aspx page) to see whether it is
correct at all? Also, you may try using a very simple aspx page to test
whether the problem is on the error page.

3. Do you have any other particular configuration setting for the certain
web application, such as formAthenticati on for page protection(fold er
protection). As for this point, you can try creating a new simple web
application and try using a custom error page to see whether the problem
remains.

Please check out the above steps and it would quite helpful if you could
provide me some more infos so as for me to repro the problem on my side.
Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 18 '05 #3
Hi Gary,
Thanks for your response. Regarding on this issue, I've done some further
research and the problem may due to the
"GetLastError() " method you used in the custom error page. Here is the
description in the KB article:
---------------
<customErrors
defaultRedirect ="http://hostName/applicationName/errorStatus.htm " mode="On">
<error statusCode="404 " redirect="filen otfound.htm" />
</customErrors>

Note The page that is specified in defaultRedirect of the <customErrors >
section is an .htm file. If you intend to use GetLastError in an .aspx page
(which the Page_Error and Application_Err or samples do), you must store the
exception in a session variable or some other approach before the redirect
takes place.

# the complete artile is accessable at the following url:
#HOW TO: Create Custom Error Reporting Pages in ASP.NET by Using Visual C#
.NET
http://support.microsoft.com/?id=306355

#HOW TO: Create Custom Error Reporting Pages in ASP.NET Using Visual Basic
.NET
http://support.microsoft.com/?id=308132
---------------

So I suggest that you try remove the "Server.GetLast Error" statement in
the custom error aspx page to see whether the problem will go away. Also,
you may try the KB's suggestion that stored the GetLastError's return value
in the Session(in Page_Error or Application_Err or event) before redirect
to the custom error aspx page, then retireve it from the Session in the
custom error page for later use.

In addition, I've searched some other references an infos on using custom
error page, you may also have a look to see whether they're helpful:
#BUG: DefaultRedirect Does Not Work When You Use SmartNavigation
http://support.microsoft.com/?id=813831

#Handling Errors(ASP.NET QuickStart)
http://samples.gotdotnet.com/quickst...rs.aspx#custom
If you feel anything unclear or need any further assistance, please feel
free to post here.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #4
Hi Gary,
Have you had a chance to try my suggestion or have you resolved the
problem? If you need any assistance, please feel
free to let me know.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Nov 18 '05 #5
Steven
It seems you did not read the message you replied to. It said....

"I have narrowed it down. It will work on an aspx page that has no code in
the codeBehind vb file. But, if I put..

If Not IsPostBack Then
lblMessage.Text = Server.GetLastE rror.Message
End If

in the Page_Load event then it does not work. The reason I wanted to use an
aspx page in the first place was because I wanted to at least inform the
user of the message so that they could report the problem. Using just an
..htm page robs the user of all information. Is there anyway to get it to
work with some code in the page? Why does it not work with code in the
page?"
As you can see, this remains a problem.
Gary

"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:5n******** ******@cpmsftng xa07.phx.gbl...
Hi Gary,
Have you had a chance to try my suggestion or have you resolved the
problem? If you need any assistance, please feel
free to let me know.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #6
Hi Gary,
Thanks for your followup. As for the problem in this issue, I've found that
you'd opened another new thread in this queue which also discussing on this
problem. I've replied you in that thread. Do you think it convenient if we
continue to discuss this problem in the new thread? If so, please feel
free to followup in the new thread if you have any questions or need any
help. Thanks.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 18 '05 #7

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

Similar topics

5
8019
by: Catherine | last post by:
I am having a problem viewing asp pages on iis version 5.1 xp pro. HTML pages are viewable on http://localhost but .asp pages are not. I have created a test program called timetest.asp with the following code: <html> <head> <title>Test ASP</title>
9
3919
by: jeanfor | last post by:
I get a http 500 error on all asp pages. When turning off the friendly message box, the message is "Class does not exist". What is the fix for that? This affect all asp pages incling the default asp pages in the default directory. Thanks
1
2115
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.
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.
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?
4
1983
by: Milsnips | last post by:
Hi there, i have 2 pages: default.aspx and getTime.aspx 1. getTime.aspx has one line: "response.write(datetime.now())" 2. default.aspx has the following html code: "<script type="text/javascript" src="getdate.aspx"></script>" When i run it it does nothing except return me a javascript error saying: Line 2, Char 12, Expected ";".. which i have got no idea here as i've only
4
6014
by: =?Utf-8?B?TWFyaw==?= | last post by:
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...
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
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9863
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
6673
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
5299
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
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3959
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.