Not sure how to send unhandled errors to the ErrorPage
I would like to capture unhandled error information, send a friendly message to the user, and receive a detailed report.
Any help or documentation references would be appreciated.
ErrorPage.aspx
<h1 style="text-align: center">
<span style="font-size: 14pt">
You found an error that I missed
</span>
</h1>
<p>
<span style="font-size: 12pt">
Use this page to report the error.
</span>
</p>
<table style="font-size: 12pt">
<tr>
<td colspan="3" style="width: 466px">
<a href="mailto:dmartin@resli
nker.com? subject=Error Report& body=I would report the following error:">
Send us the error report</a>
</td>
<td style="width: 100px">
<asp:Button ID="btnSendError" runat="server" Text="Send Report" Width="101px" /></td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td colspan="3" style="width: 466px">
<asp:TextBox ID="txtErrorMsg" runat="server" Height="34px" Rows="8" TextMode="MultiLine"></asp
:TextBox><
/td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
</tr>
</table>
<span style="font-size: 14pt"></span>
ErrorPage.aspx/vb
Imports System.Net.Mail
Imports System.Diagnostics
Partial Class ErrorPage
Inherits System.Web.UI.Page
Protected Sub btnSendError_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSendError.Click
Dim objClient As New SmtpClient
Dim objEMail As New MailMessage
Dim strMsg As String = ""
Dim strTo As String = ""
'Dim ErrorMessage = "The error description is as follows : " & Server.GetLastError.ToStri
ng
Dim ErrorMessage As String = ""
If Not Server.GetLastError Is Nothing Then
ErrorMessage = "The error description is as follows : " & Server.GetLastError().Inne
rException
.ToString(
)
Me.txtErrorMsg.Text = ErrorMessage
End If
strTo = "dovberman@cableone.net"
'objClient.Host = "localhost"
objClient.DeliveryMethod = SmtpDeliveryMethod.Specifi
edPickupDi
rectory
objClient.PickupDirectoryL
ocation = "C:\Inetpub\mailroot\Picku
p"
objEMail.To.Add(New MailAddress("dmartin@resli
nker.com")
)
objEMail.From = New MailAddress("dovberman@cab
leone.net"
)
objEMail.Subject = "My Stock Picker Error Report"
objEMail.Body = ErrorMessage
Try
objClient.Send(objEMail)
Response.Write("Your E-mail has been sent sucessfully")
Catch exc As Exception
Response.Write("Send failure: " + exc.ToString())
End Try
End Sub