Email problem with custom error page

admin

Administrator
Staff member
Hi, I have an error page with code behind page that sends an email with exception to my email addy.
However when the page with the error on it is submitted the progress bar bottom right gradually fills and flickers and thats it no custom error page no email.

I I remove the code from code behind page and global asx then the error page appears no problem.

IIS has virtual smtp server installed
asp.net 2.0
server2003
.vb code behind

have attached global.asax and error.aspx.vb or not as seems the case.Hi, I have an error page with code behind page that sends an email with exception to my email addy.
However when the page with the error on it is submitted the progress bar bottom right gradually fills and flickers and thats it no custom error page no email.

I I remove the code from code behind page and global asx then the error page appears no problem.

IIS has virtual smtp server installed
asp.net 2.0
server2003
.vb code behind

have attached global.asax and error.aspx.vb or not as seems the case.
global.asax file....

<script runat="server">


Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
End Sub

Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application shutdown
End Sub

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
'Code that runs when an unhandled error occurs
Dim ex As Exception
ex = Server.GetLastError.InnerException
Session("Exception") = ex
Response.Redirect("ErrorPage.aspx")
End Sub

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a new session is started
End Sub

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a session ends.
' Note: The Session_End event is raised only when the sessionstate mode
' is set to InProc in the Web.config file. If session mode is set to StateServer
' or SQLServer, the event is not raised.
End Sub

</script>

code behind error.aspx.vb....

Protected Sub page_load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Me.SendEmail(Session("Exception"))
Session.Remove("Exception")
End If
End Sub

Private Sub SendEmail(ByVal ex As Exception)
Dim sBody As String
sBody = " An exception has occurred at " & Now.ToLongTimeString() _
& " on " & Now.ToLongDateString() & "<br />" & ex.Message
Dim msg As New MailMessage("[email protected]", "[email protected]")
msg.Subject = "Exception in Loans Application"
msg.Body = sBody
msg.IsBodyHtml = True
Dim client As New SmtpClient("localhost")
client.Send(msg)

End SubYou might juse want to look into ASP.net 2.0's Health Monitoring.

Just add a few lines in the web.config file and good to go. The error is on the page ErrorPage.aspx !!!
 
Back
Top