can not redirect to customized error page

H

haiwen

Hello, everyone.

I am in trouble to create an error page for my application.

in Web.config file:
<customErrors defaultRedirect="errorPage.aspx"
mode="On" />

in one .aspx
private void Page_Load(object sender, System.EventArgs e)
{
throw(new Exception("try!!!"));
}

But when the error occur, my application can not
redirected to errorPage.aspx that my customized error page.

Even I try other ways, such as in <%@Page
ErrorPage="errorPage.aspx" ... %>

or
private void Page_Error(object sender, System.EventArgs e)

{
Response.Redirect("errorPage.aspx");
}

But I still can not redirect to the errorPage.aspx when
error occur.

Could anyone help? I do appreciate your help!!!

Best Wishes,

haiwen
 
H

haiwen

Hello, everyone,

I find out my application redirects to the error page, but
there is a error in the customized error page.
That is I have code:
Label1.Text=Server.GetLastError().Message;

but the Server.GetLastError() return null???
It seems I can not get the exception?

Could anyone help?

Sincerely,

haiwen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top