页面在发生错误的时候执行:
protected void Page_Error(object sender, EventArgs e)
{
Exception ex = Server.GetLastError();
if (ex is HttpRequestValidationException)
{
Response.Redirect("Default.aspx");
Server.ClearError();
}