62,041
社区成员
发帖
与我相关
我的任务
分享
protected void Application_Error(object sender, EventArgs e)
{
// 在出现未处理的错误时运行的代码
Exception ex = Server.GetLastError();
if (ex is HttpRequestValidationException)
{
Response.Write("请您输入合法字符串。");
Server.ClearError(); // 如果不ClearError()这个异常会继续传到Application_Error()。
}
else { Response.Redirect(Request.RawUrl.Split('?')[0]); }
}