Page_Error Working Only Part of the Time?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Erik Lautier

    Page_Error Working Only Part of the Time?

    I've got Page_Error emailing me the message and stack trace when a
    server error is generated, but it doesn't always work. My Page_Error
    code:

    Sub Page_Error(ByVa l src As Object, ByVal args As EventArgs) Handles
    MyBase.Error
    Dim e As System.Exceptio n = Server.GetLastE rror()
    Session("Erro") = "Error: " & e.Message.ToStr ing() & "<p>Stack Trace: "
    & e.StackTrace.To String()
    Context.ClearEr ror()
    End Sub

    My web.config file redirects the user to a "nice" error page, which
    emails me the Session("Erro") so I can investigate the problem. What
    I can't understand is that sometimes Session("Erro") is blank - I saw
    two emails come through with errors on the same page today, with one
    full of useful info, and one completely empty. What might explain
    this?

    Thanks,

    Erik
  • Michael Nemtsev [MVP]

    #2
    Re: Page_Error Working Only Part of the Time?

    Hello Erik,

    it means that u dont' have previous error.

    Why you don't handle all errors on Application_Err or method?

    ---
    WBR,
    Michael Nemtsev [Microsoft MVP] :: blog: http://spaces.live.com/laflour

    "The greatest danger for most of us is not that our aim is too high and we
    miss it, but that it is too low and we reach it" (c) Michelangelo


    ELI've got Page_Error emailing me the message and stack trace when a
    ELserver error is generated, but it doesn't always work. My Page_Error
    ELcode:
    EL>
    ELSub Page_Error(ByVa l src As Object, ByVal args As EventArgs) Handles
    ELMyBase.Error
    ELDim e As System.Exceptio n = Server.GetLastE rror()
    ELSession("Erro ")= "Error: " & e.Message.ToStr ing() & "<p>Stack Trace:
    EL"
    EL& e.StackTrace.To String()
    ELContext.Clear Error()
    ELEnd Sub
    ELMy web.config file redirects the user to a "nice" error page, which
    ELemails me the Session("Erro") so I can investigate the problem.
    ELWhat I can't understand is that sometimes Session("Erro") is blank -
    ELI saw two emails come through with errors on the same page today,
    ELwith one full of useful info, and one completely empty. What might
    ELexplain this?
    EL>
    ELThanks,
    EL>
    ELErik
    EL>


    Comment

    • Erik Lautier

      #3
      Re: Page_Error Working Only Part of the Time?

      Thanks for your reply, Michael. It's not my server and I may not have
      access to global.asax (I'm checking on this). Regardless, if
      Page_Error is supposed to pull the last error and I'm storing it in a
      Session variable, how could I not have the previous error?

      On Jun 17, 1:08 pm, Michael Nemtsev [MVP] <nemt...@msn.co mwrote:
      Hello Erik,
      >
      it means that u dont' have previous error.
      >
      Why you don't handle all errors on Application_Err or method?
      >
      ---
      WBR,
      Michael Nemtsev [Microsoft MVP] :: blog:http://spaces.live.com/laflour
      >
      "The greatest danger for most of us is not that our aim is too high and we
      miss it, but that it is too low and we reach it" (c) Michelangelo
      >
      ELI've got Page_Error emailing me the message and stack trace when a
      ELserver error is generated, but it doesn't always work. My Page_Error
      ELcode:
      EL>
      ELSub Page_Error(ByVa l src As Object, ByVal args As EventArgs) Handles
      ELMyBase.Error
      ELDim e As System.Exceptio n = Server.GetLastE rror()
      ELSession("Erro ")= "Error: " & e.Message.ToStr ing() & "<p>Stack Trace:
      EL"
      EL& e.StackTrace.To String()
      ELContext.Clear Error()
      ELEnd Sub
      ELMy web.config file redirects the user to a "nice" error page, which
      ELemails me the Session("Erro") so I can investigate the problem.
      ELWhat I can't understand is that sometimes Session("Erro") is blank -
      ELI saw two emails come through with errors on the same page today,
      ELwith one full of useful info, and one completely empty. What might
      ELexplain this?
      EL>
      ELThanks,
      EL>
      ELErik
      EL>


      Comment

      Working...