0

I like to user custom errors in my site. The Idea is to trap errors and display friendly meaningful messages to users. The real error details (line number, Page ...) will sent to me by e-mail. I am programming in VB.NET. Until now every code that i found about this say's that i must use the global.asax for it. I do not like to use global.asax, I just like to make an error page that will sent me a -email with all the error details. Until now, i go to the web.config file and insert this line:

<customErrors defaultRedirect="test.aspx" mode="On"></customErrors>

test.aspx looks like this:

Sub Page_Error(sender as Object, e as EventArgs) Dim ctxOBJ As HttpContext Dim exceptionOBJ As Exception Dim errorInfoTXT As String ctxOBJ = HttpContext.Current() exceptionOBJ = ctxOBJ.Server.GetLastError() errorInfoTXT = "
Offending URL: " & ctxOBJ.Request.Url.ToString() & _ "
Source: " & exceptionOBJ.Source.ToString() & _ "
Message: " & exceptionOBJ.Message.ToString() & _ "
Stack trace: " & exceptionOBJ.StackTrace.ToString() & _ "

Target Site: " & exceptionOBJ.TargetSite.ToString() ctxOBJ.Response.Write (errorInfoTXT) ctxOBJ.Server.ClearError () End Sub

When here is an error in some page its redirect me to test.aspx but not showing any error.

Thanks,

Roy Shoa.

1 Answer 1

1

You just need to change this to

Sub Page_Load(sender as Object, e as EventArgs)

It's not the error page that's erroring, so its error event never fires.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.