Customize Error Page

  • Thread starter Thread starter Shabam
  • Start date Start date
S

Shabam

When I set validateRequest="true", and a user tries to submit html into the
form, the server returns with a huge error page detailing what wasn't
allowed.

Is there a way to customize just this error page to something more friendly?
I want to use different error pages for other things, but for this one I'd
like to customize it. Is this possible?
 
One approach would be to catch the error from the Application_Error
procedure in your Global.asax file. e.g.:

protected void Application_Error(Object sender, EventArgs e)
{
Exception ex = Server.GetLastError();
if (ex is HttpRequestValidationException)
{
// Do one thing.
}
else
{
// Do something else.
}
}

HTH,
Nicole
 
Back
Top