This should be something easy (famous last words) I have a default error redirect page which works just great, but I am trying to capture some additional information about the error and store it in an error table or email it back to myself. Below is what I got so far:
Code:CustomErrorPage.aspx
<form id="form1" runat="server" class="ErrorForm">
<div class="YellowText">
<h2>Error:</h2>
<p>
A problem has occurred. We apologize for any
inconvenience this may cause. Please reload
the application by pressing the F5 function key.
If this problem persists contact the
application developer at (999) 999-9999
</p>
<p>
<b>The Error occured at:</b><br />
<asp:Label ID="ErrorLabel" runat="server" Text="Label"></asp:Label>
</p>
</div>
</form>
</body>
</html>
CustomErrorPage.aspx.vb
Imports System.Web
Imports System.Web.Configuration
Partial Class CustomErrorPage
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim vErrorPage As String = Request("aspxerrorpath")
ErrorLabel.Text = vErrorPage
End Sub
End Class
Web.config
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="CustomErrorPage.aspx"/>
</system.web>
I have tried capturing the exception information in my on-load event using:
but then I get this error:Code:Dim objErr As Exception
Dim vStr As String
objErr = Server.GetLastError()
vStr = objErr.StackTrace.ToString
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
Of course when I follow the suggested solution my redirect no longer works.
I have also played around with the following since it seems exactly what I am looking for but I can’t get it to work.
Any suggestions on how I might approach this?Code:<%
Response.Write("ASPCode=" & objErr.ASPCode)
Response.Write("<br />")
Response.Write("ASPDescription=" & objErr.ASPDescription)
Response.Write("<br />")
Response.Write("Category=" & objErr.Category)
Response.Write("<br />")
Response.Write("Column=" & objErr.Column)
Response.Write("<br />")
Response.Write("Description=" & objErr.Description)
Response.Write("<br />")
Response.Write("File=" & objErr.File)
Response.Write("<br />")
Response.Write("Line=" & objErr.Line)
Response.Write("<br />")
Response.Write("Number=" & objErr.Number)
Response.Write("<br />")
Response.Write("Source=" & objErr.Source)
%>
Thanks for your help.

