redirect and mail on error

RTT

Active member
Joined
Mar 16, 2005
Messages
26
Programming Experience
Beginner
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:
VB.NET:
<customErrors defaultRedirect="error.htm" mode="RemoteOnly" />

in the global.asax i added:
VB.NET:
 Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) 
'Fires when an error occurs
sendmail(Server.GetLastError)
End Sub

with the function:
VB.NET:
 Dim mail As New MailMessage 
mail.To = """name"" <email@email.com>"
mail.From = """ Error "" <email@email.com>"
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?
 
Back
Top