Results 1 to 4 of 4

Thread: [Resolved] redirect and mail on error

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    32

    [Resolved] redirect and mail on error

    i want to make it so, that when an error accurs, the people get redirected to an error page, and that the error is being send to me.



    in the web.config file i added:
    Code:
    <customErrors defaultRedirect="error.htm" mode="RemoteOnly" />


    in the global.asax i added:

    Code:
     Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) 
       'Fires when an error occurs
       sendmail(Server.GetLastError)
    End Sub


    with the function:

    Code:
     Dim mail As New MailMessage 
    mail.To = """name"" <[email protected]>"
    mail.From = """ Error "" <[email protected]>"
    
    mail.BodyFormat = MailFormat.Html
    mail.Priority = MailPriority.High
    mail.Subject = "Error Report - " & Date.Now.ToString
    mail.Body = ""
    mail.Body += "<u><b>ErrorMessage:</b></u><br>"
    mail.Body += Ex.Message.ToString & "<br><br>"
    mail.Body += "<b>exception: </b>" & ex.ToString
    mail.Body += "<br><br><b>Reported on: </b>" & Date.Now.ToString
    SmtpMail.SmtpServer = "BEXXGHE01IS0020"
    SmtpMail.Send(mail)


    it works, i get an email when an error accurs and the user is redirected, but i always get something like this:



    ErrorMessage:
    Exception of type System.Web.HttpUnhandledException was thrown.

    exception: System.Web.HttpUnhandledException: Exception of type System.Web.HttpUnhandledException was thrown. ---> System.IndexOutOfRangeException: There is no row at position 4. at System.Data.DataRowCollection.get_Item(Int32 index) at ResourcesManagement1.containersOverview.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\ResourcesManagement1\Asp\containersOverview.aspx.vb:line 68 at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain() --- End of inner exception stack trace --- at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain() at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

    Reported on: 04/04/2005 11:05:57


    the error is always of the type System.Web.HttpUnhandledException, while i know the error should be of other types. anybody who knows what causes this and how to solve it?
    Last edited by RTT2001; Apr 4th, 2005 at 05:07 AM.

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