CustomErrorPage

  • Thread starter Thread starter Seb
  • Start date Start date
S

Seb

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?
 
HERE YOU go with one custom error page with mail
functionality
<customErrors mode="Off" defaultRedirect="err.aspx">
<error statusCode="500" redirect="err.aspx"/>
<error statusCode="404" redirect="err.aspx"/>
<error statusCode="403" redirect="err.aspx"/>
</customErrors>

Imports System.Web.Mail
Public Class Error_Page
Inherits System.Web.UI.Page
Protected WithEvents btSend As
System.Web.UI.WebControls.Button
Protected WithEvents Label5 As
System.Web.UI.WebControls.Label
Protected WithEvents Label4 As
System.Web.UI.WebControls.Label
Protected WithEvents Label3 As
System.Web.UI.WebControls.Label
Protected WithEvents Label2 As
System.Web.UI.WebControls.Label
Protected WithEvents HyperLink1 As
System.Web.UI.WebControls.HyperLink
Protected WithEvents tbWhat As
System.Web.UI.WebControls.TextBox
Protected WithEvents tbWhen As
System.Web.UI.WebControls.TextBox
Protected WithEvents tbFrom As
System.Web.UI.WebControls.TextBox
Protected WithEvents tbMessage As
System.Web.UI.WebControls.Label
Protected WithEvents Label1 As
System.Web.UI.WebControls.Label

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web
Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
tbWhen.Text = Now.ToString
If Not Cache("UserName") Is Nothing Then
tbFrom.Text = CType(Cache("UserName"), String)
End If
End Sub

Private Sub btSend_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) 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.SmtpServer = ""
SmtpMail.Send(mail)
tbMessage.Visible = True
End Sub

End Class
 
Back
Top