Dec 21, 2009, 9:04 AM
catch HttpRequestValidationException
hi there, i'm trying to catch the HttpRequestValidationException through the global.ascx but can't somehow get the error using the ajaxevent failure property
Exception ex = Server.GetLastError();
if (ex is HttpRequestValidationException)
{
Response.Clear();
Response.StatusCode = 200;
string response = "<html><head><title>HTML Not Allowed</title>";
response += "</head>";
response += "<body style=\"font-family: Arial, Sans-serif;\">";
response += "<p>I'm sorry, but HTML entry is not allowed on that page.</p>";
response += "<p>Please make sure that your entries do not contain ";
response += "any angle brackets like &lt; or &gt;.</p>";
response += "<p><a href=\"history.go(-1);\">Go back</a></p>";
response += "</body></html>";
Response.Write(response);
Response.End();
}