GetLastError in defaultRedirect page?

G

Guest

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"/>

Thanks, Dave.
 
S

Saravana [MVP]

Server.getlasterror will be null during that time, you can use
server.lasterror only at Page_OnError to get the exception. So in
Page_onError, get the exception and store in session and then redirect to
your AppError.aspx . From the session get that value and display your custom
error message to the user

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com



Dave said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top