当输入框中含有Html标签时页面报错,跟踪发现是“从客户端()中检测到有潜在危险的 Request.Form 值”异常,但设置“ValidateRequest="false"”后没有效果,发现还是弹出错误提示,且提示为“Sys.WebForms.PageRequestManagerServerErrorException: 在服务器上处理请求时出现未知错误。服务器返回的状态码为: 500 ”。当前页面为母版页的内容页,且页面中含有updatepanel。如果设置Page_Error事件,如果调用Response.Write或ScriptManager.RegisterStartupScript弹出提示的话,页面也会弹出同样错误提示,代码如下:
protected void Page_Error(object sender, EventArgs e)
{
Exception ex = HttpContext.Current.Server.GetLastError();
if (ex is HttpRequestValidationException)
{
//ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(UpdatePanel), "msg", "alert('请输入合法的字符串!');", true);
//HttpContext.Current.Response.Write("<script>alert('请输入合法的字符串!');</script>");
HttpContext.Current.Server.ClearError();
}
}
请问如何解决,谢谢
protected void Page_Error(object sender, EventArgs e)
{
Exception ex = HttpContext.Current.Server.GetLastError();
if (ex is HttpRequestValidationException)
{
//ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(UpdatePanel), "msg", "alert('请输入合法的字符串!');", true);
//HttpContext.Current.Response.Write("<script>alert('请输入合法的字符串!');</script>");
HttpContext.Current.Server.ClearError();
}
}
请问如何解决,谢谢
解决方案 »
- 求教育:在SqlDataSource中,如何使用UpdateCommand,DeleteCommand更新、删除多个表?
- 救急。。。
- Repeater用分页控件显示不出以后的数据
- 请大家发一些javascript特效下载的网址
- 100分未解决问题,继续提
- Type t = Type.GetType( "項目里空間名.類型 ");this.Response.Write(t.ToString());第二句出錯,t為空,為什么?
- 关于vs2005下面水晶报表的问题
- 请教如何将String转换成char
- 关于jmail的问题?
- 急求教两个问题?
- aasp.net中CKEditor3.6.2的详细使用方法!
- asp.net 去除html标记 在线等,急急!!!
例如 把 < 转义成 < 等等