Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim strError As String
Dim objError As System.Exception = HttpContext.Current.Application.Get("lastException")
lblTitle.Text = "Application Error!"
lblmessage.Text = "There has been an unexpected error. Administration have been informed. Please try again later."
'now send an email to the admin
Try
strError &= vbNewLine
strError &= objError.GetBaseException.Message & vbNewLine
strError &= objError.GetBaseException.StackTrace
strError &= vbNewLine & "Source : " & objError.GetBaseException.Source
Catch ex As Exception
strError = "Unable to obtain error information"
End Try
Try
Dim ErrorUrl As String = Request.Params("aspxerrorpath").ToString
Dim strErrormsg As String
If User.Identity.IsAuthenticated Then
strErrormsg = "An Error has occurred on xxx.co.uk, user ID: " & User.Identity.Name & " requested the page " & ErrorUrl & ". "
Else
strErrormsg = "An Error has occurred on xxx.co.uk, An unauthenticated user requested the page " & ErrorUrl & ". "
End If
Dim ObjMM As New MailMessage
ObjMM.To = "xxx.co.uk"
ObjMM.Subject = "xxx Site Error"
ObjMM.Body = strErrormsg
ObjMM.Body &= vbNewLine & strError
ObjMM.BodyFormat = MailFormat.Text
SmtpMail.SmtpServer = "smtp.xxx.co.uk"
SmtpMail.Send(ObjMM)
Catch
End Try
FormsAuthentication.SignOut()
Session.Abandon()
End Sub