HERE YOU go with one custom error page with mail
functionality
<customErrors mode="Off" defaultRedirect ="err.aspx">
<error statusCode="500 " redirect="err.a spx"/>
<error statusCode="404 " redirect="err.a spx"/>
<error statusCode="403 " redirect="err.a spx"/>
</customErrors>
Imports System.Web.Mail
Public Class Error_Page
Inherits System.Web.UI.P age
Protected WithEvents btSend As
System.Web.UI.W ebControls.Butt on
Protected WithEvents Label5 As
System.Web.UI.W ebControls.Labe l
Protected WithEvents Label4 As
System.Web.UI.W ebControls.Labe l
Protected WithEvents Label3 As
System.Web.UI.W ebControls.Labe l
Protected WithEvents Label2 As
System.Web.UI.W ebControls.Labe l
Protected WithEvents HyperLink1 As
System.Web.UI.W ebControls.Hype rLink
Protected WithEvents tbWhat As
System.Web.UI.W ebControls.Text Box
Protected WithEvents tbWhen As
System.Web.UI.W ebControls.Text Box
Protected WithEvents tbFrom As
System.Web.UI.W ebControls.Text Box
Protected WithEvents tbMessage As
System.Web.UI.W ebControls.Labe l
Protected WithEvents Label1 As
System.Web.UI.W ebControls.Labe l
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web
Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles MyBase.Load
If Not Page.IsPostBack Then
tbWhen.Text = Now.ToString
If Not Cache("UserName ") Is Nothing Then
tbFrom.Text = CType(Cache("Us erName"), String)
End If
End Sub
Private Sub btSend_Click(By Val sender As
System.Object, ByVal e As System.EventArg s) Handles
btSend.Click
Dim mail As New MailMessage()
With mail
.From = ""
.To = ""
.Subject = "Error at soltn"
.Body = "When : " & tbWhen.Text & "<br>"
.Body = .Body + "What : " & tbWhat.Text
& "<br>"
.Body = .Body + "From : " & tbFrom.Text
& "<br>"
.BodyFormat = MailFormat.Html
End With
SmtpMail.SmtpSe rver = ""
SmtpMail.Send(m ail)
tbMessage.Visib le = True
End Sub
End Class
-----Original Message-----
Hello All,
Trying the first time to use a custom ErrorPage
using:
<customErrors
mode="On"
defaultRedirect ="TR_Error.aspx "
/>
in the Web.config
Somehow the Application never reaches this page!
(I still see the ASP-Default-ErrorPage)
What might be wrong here?
Has anyone got a ErrorPage-Example?
.