Results 1 to 2 of 2

Thread: Custom Error Page

  1. #1

    Thread Starter
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Custom Error Page

    I have a custom error that displays ok but i also wanted to send a detailed email to the site admin informing them of the error.

    I've found several examples that seem to do this by setting
    VB Code:
    1. <customErrors mode="On" defaultRedirect="errorpage.aspx" />
    In the web.config file.

    From this i can get the path for the file that caused the error as such
    VB Code:
    1. Dim ErrorUrl As String = Request.Params("aspxerrorpath").ToString
    I'd also like to get more detailed information though which i've tried doing as specified in the many samples i've found
    VB Code:
    1. Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
    2.         ' Fires when an error occurs
    3.         Dim objError As Exception = Server.GetLastError()
    4.         HttpContext.Current.Application.Add("lastException", objError)
    5.         Server.ClearError()
    6.     End Sub
    The idea then being to build up the body of the email to send with the path of the error and a detailed description of it. But i don't seem to be able to get both events to fire as if i have code in the application_error event then the user doesn't get redirected to the errorpage.

    Any idea's whats going wrong/on?

  2. #2

    Thread Starter
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092
    I've managed to get it working by removing the line
    VB Code:
    1. server.clearError()
    from the application_error sub.

    Does anyone know why this is or what implications it have?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width