Senting Errors to Cusom Error page

28 views
Skip to first unread message

Sam

unread,
Aug 27, 2006, 7:24:25 AM8/27/06
to ELMAH
Hi

I use ELMAH 1.0 with ASP.NET 1.1 on SQL Server 2000 to log error for
my website.

When an error occurs, I am now sending the user to a custom error page,
but I am unable to show some of the actual errors on the custom error
page.

Following is my web.config info:
<customErrors mode="On" defaultRedirect="genericerror.aspx" />

When an error occurs for example:
"System.IO.FileNotFoundException: H:\mypage\contact.aspx"

I want this to show up on my custom error page.

I also want the HOST, Code, user, date and time to show up as well.

Any help would be appriciated.
Thanks in advance
Sam

Atif Aziz

unread,
Aug 27, 2006, 7:25:05 PM8/27/06
to el...@googlegroups.com
You can't really use the custom error pages for this, which is designed
for displaying generic messages. For something more involved as you'd
like, you need another approach and completely bypass the custom error
pages facility provided by ASP.NET out of the box. What I usually do is
to trap the Application_Error event in the Global.asax and render a
custom error page as a response to the actual request (not a redirect).
In the Application_Error handler, use a Server.Transfer to emit a custom
error page. In the custom error page, you can use Server.GetLastError to
get the exception object and find out the cause of the error and display
the information you want to the user.

Eric

unread,
Aug 27, 2006, 8:20:16 PM8/27/06
to ELMAH
If you need mor information, look at this article:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/customerrors.asp

It tells you all the obstacle with the GetLastError and Custom error
page.

Sam

unread,
Sep 2, 2006, 6:47:01 AM9/2/06
to ELMAH
I have desided to use generic message and created a button to view all
the messages.
Thank You.
Sam

Reply all
Reply to author
Forward
0 new messages