Results 1 to 8 of 8

Thread: send error

  1. #1

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    send error

    Hi,

    I would like to know if it's possible if at anytime an error occur on my server, i would like to receive an email with description of the error.

    Thanks

  2. #2

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Re: send error

    i was able to do this, But i would like to see exactly what user will see on the error page.

    Thanks

    vb Code:
    1. Protected Sub Page_Error(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Error
    2.  
    3.         Dim loginInfo3 As New NetworkCredential("xxxxx@gmail.com", "xxxxx")
    4.         Dim msg3 As New MailMessage("xxxx@gmail.com", "xxxx@gmail.com", Server.GetLastError.Message.ToString, Server.GetLastError.ToString)
    5.         ' msg3.IsBodyHtml = True
    6.         Dim client3 As New SmtpClient("smtp.gmail.com", 587)
    7.  
    8.  
    9.         client3.EnableSsl = True
    10.         client3.UseDefaultCredentials = False
    11.         client3.Credentials = loginInfo3
    12.  
    13.  
    14.         client3.Send(msg3)
    15.  
    16.     End Sub

  3. #3
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: send error

    You can handle the Application_Error to handle all unhandled exceptions.

    Personally, I'd create an object that handles the error sending. Then, whenever you catch an exception, use this object. Things like web services will not trigger the Page_Error or Application_Error events.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  4. #4
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: send error

    Absolutely, the majority of your code should be written in such a way that error/exceptions are handled at the place that it occurs. i.e. correct use of Try/Catches. However, there are times that things happen that aren't anticipated, this is where Page/Application level error handling comes in. However, the point I am making is that you shouldn't rely on this.

    Gary

  5. #5

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Re: send error

    Hi,

    I do use Try/Catches in my code, but there are some kind of errors that its not catching, it's for that reason that i wanted to use Page/Application level error handling.

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,173

    Re: send error

    Application_Error in global.asax.

    http://msdn.microsoft.com/en-us/library/24395wz3.aspx

    Send the email from there.

  7. #7
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: send error

    Quote Originally Posted by met0555 View Post
    Hi,

    I do use Try/Catches in my code, but there are some kind of errors that its not catching, it's for that reason that i wanted to use Page/Application level error handling.
    And that is the point that I was trying to make. I am not saying that it is wrong to use Application Error Handling, but rather, if and when an Application Error is caught, I would be doing some investigation as to what is causing that error and try and handle it elsewhere.

    Gary

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,173

    Re: send error

    Have a look at Log4Net as well. There are many 'options' as to how the exceptions are processed (file, email, database, etc).

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