redirect and mail on error


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

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

with the function:
 Dim mail As New MailMessage 
mail.To = """name"" <>"
mail.From = """ Error "" <>"
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"

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

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?
Top Bottom