HttpRequestValidationException and custom error page
Hi,
I'm having trouble getting a custom error page for the HttpRequestValidationException. I definitely want to have ASP.NET checking the user input. But I need to show a page with a more user friendly message.
What I tried up to now is deriving a new Global class from UmbracoApplication and overriding OnApplicationError. If the user enters invalid code, the hander is getting executed. But whatever I try to do in the handler, I always get the standard yellow error page.
I tried the following two versions:0
protected override void OnApplicationError( object sender, EventArgs e ) { Exception ex = Server.GetLastError(); if ( ex is HttpRequestValidationException ) { Response.Redirect( "https://login.al.de/fehler.aspx" ); } }
And
protected override void OnApplicationError( object sender, EventArgs e ) { Exception ex = Server.GetLastError(); if ( ex is HttpRequestValidationException ) { Response.Clear(); Response.StatusCode = 200; Response.Write( @"<html><head><title>HTML Not Allowed</title><script language='JavaScript'><!--function back() { history.go(-1); } //--></script></head><body style='font-family: Arial, Sans-serif;'><h1>Oops!</h1><p>I'm sorry, but HTML entry is not allowed on that page.</p><p>Please make sure that your entries do not contain any angle brackets like < or >.</p><p><a href='javascript:back()'>Go back</a></p></body></html>" ); Response.End(); } }
Nothing of it works.
Does anybody has an idea of how to get this to work? I'm using Umbraco 6.0.6.
HttpRequestValidationException and custom error page
Hi,
I'm having trouble getting a custom error page for the HttpRequestValidationException. I definitely want to have ASP.NET checking the user input. But I need to show a page with a more user friendly message.
What I tried up to now is deriving a new Global class from UmbracoApplication and overriding OnApplicationError. If the user enters invalid code, the hander is getting executed. But whatever I try to do in the handler, I always get the standard yellow error page.
I tried the following two versions:0
protected override void OnApplicationError( object sender, EventArgs e )
{
Exception ex = Server.GetLastError();
if ( ex is HttpRequestValidationException )
{
Response.Redirect( "https://login.al.de/fehler.aspx" );
}
}
And
protected override void OnApplicationError( object sender, EventArgs e )
{
Exception ex = Server.GetLastError();
if ( ex is HttpRequestValidationException )
{
Response.Clear();
Response.StatusCode = 200;
Response.Write( @"<html><head><title>HTML Not Allowed</title><script language='JavaScript'><!--function back() { history.go(-1); } //--></script></head><body style='font-family: Arial, Sans-serif;'><h1>Oops!</h1><p>I'm sorry, but HTML entry is not allowed on that page.</p><p>Please make sure that your entries do not contain any angle brackets like < or >.</p><p><a href='javascript:back()'>Go back</a></p></body></html>" );
Response.End();
}
}
Nothing of it works.
Does anybody has an idea of how to get this to work? I'm using Umbraco 6.0.6.
Regards
Mirko
is working on a reply...