J
John Lau
Hi,
I am looking at the MS KB Article 306355: HOW TO: Create Custom Error
Reporting Pages in ASP.NET by Using Visual C# .NET
This article describes how to redirect errors to a custom html error page.
All six steps in the article work just fine. Then at the end of the
article, there is a little comment about redirecting errors to an aspx page
(instead of an html page):
"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_Error samples do), you must store the
exception in a session variable or some other approach before the redirect
takes place."
So I stored the exception in a session variable, and changed the
customErrors section to redirect the user to ErrorStatus.aspx instead of
errorStatus.htm.
<customErrors defaultRedirect="http://localhost/WebDemo/ErrorStatus.aspx"
mode="On" />
But instead of redirecting to the ErrorStatus.aspx page, the application
remained on the login.aspx page, and the ReturnUrl is set to the
ErrorStatus.aspx page (according to the address in the browser).
http://localhost/WebDemo/login.aspx.../login.aspx&aspxerrorpath=/WebDemo/login.aspx
Interestingly, if, in the Application_Error method in the Global.asax file,
I manually send the user to ErrorStatus.aspx using Response.Redirect, the
redirect is ignored. If I use Server.Transfer, it works. According to the
note in the article, I should not need to use Response.Redirect or
Server.Transfer.
Has anyone come across this problem?
Thanks,
John
I am looking at the MS KB Article 306355: HOW TO: Create Custom Error
Reporting Pages in ASP.NET by Using Visual C# .NET
This article describes how to redirect errors to a custom html error page.
All six steps in the article work just fine. Then at the end of the
article, there is a little comment about redirecting errors to an aspx page
(instead of an html page):
"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_Error samples do), you must store the
exception in a session variable or some other approach before the redirect
takes place."
So I stored the exception in a session variable, and changed the
customErrors section to redirect the user to ErrorStatus.aspx instead of
errorStatus.htm.
<customErrors defaultRedirect="http://localhost/WebDemo/ErrorStatus.aspx"
mode="On" />
But instead of redirecting to the ErrorStatus.aspx page, the application
remained on the login.aspx page, and the ReturnUrl is set to the
ErrorStatus.aspx page (according to the address in the browser).
http://localhost/WebDemo/login.aspx.../login.aspx&aspxerrorpath=/WebDemo/login.aspx
Interestingly, if, in the Application_Error method in the Global.asax file,
I manually send the user to ErrorStatus.aspx using Response.Redirect, the
redirect is ignored. If I use Server.Transfer, it works. According to the
note in the article, I should not need to use Response.Redirect or
Server.Transfer.
Has anyone come across this problem?
Thanks,
John