Monday, March 26, 2012

Why Page_Error cant catch an HttpRequestValidationException?

I have the following code in Page_Error handler subroutine:

Exception ex =Server.GetLastError();
Response.Write(ex.Message);
Response.Write(ex.StackTrace);
Server.ClearError();

But it doesn't work when an HttpRequestValidationException occurs(I input a
html tag into the TextBox control in the page and submit it).I have attach
the Page.Error event to it's handler--the Page_Error subroutine.the same
code in the Application_Error works well.Why?It would make sense having ASP.NET to perform this check before loading the
page... (you can check the call stack to make sure).

Patrice

"bondzhou" <zhouyuemail@.sohu.com> a crit dans le message de
news:uJ6QdhQTEHA.332@.TK2MSFTNGP11.phx.gbl...
> I have the following code in Page_Error handler subroutine:
> Exception ex =Server.GetLastError();
> Response.Write(ex.Message);
> Response.Write(ex.StackTrace);
> Server.ClearError();
> But it doesn't work when an HttpRequestValidationException occurs(I input
a
> html tag into the TextBox control in the page and submit it).I have attach
> the Page.Error event to it's handler--the Page_Error subroutine.the same
> code in the Application_Error works well.Why?

0 comments:

Post a Comment