我在global_error中写了错误处理,并且在一个错误页面error.aspx中显示错误信息,但是现在有个问题,就是global_error中只是捕获页面级错误,而其他错误不可以捕获,比如我想跳转到一个不存在的页面,也就是404错误他就捕捉不到,我在webconfig中写了错误页面是可以捕获到这个404错误的,但是不可能除了页面错误就只有404错误啊,其他错误怎么办,总不能在webconfig中一个一个写吧,请教各位高手应该怎么做??
在global_error中的代码
protected void Application_Error(Object sender, EventArgs e)
{
Exception Error = Server.GetLastError();
if (Error != null)
{
Server.Transfer(this.Request.ApplicationPath + "\\Error.aspx");
}
}在webconfig中的代码
<configuration>
<system.web>
<customErrors
mode="On">
<error statusCode="404"
redirect="http://localhost/WebApplication1/404error.aspx"/>
</customErrors>
</system.web>
</configuration>
在global_error中的代码
protected void Application_Error(Object sender, EventArgs e)
{
Exception Error = Server.GetLastError();
if (Error != null)
{
Server.Transfer(this.Request.ApplicationPath + "\\Error.aspx");
}
}在webconfig中的代码
<configuration>
<system.web>
<customErrors
mode="On">
<error statusCode="404"
redirect="http://localhost/WebApplication1/404error.aspx"/>
</customErrors>
</system.web>
</configuration>
解决方案 »
- Repeater绑定数据
- 我要在页面上显示<a></a>,而不是把<用lt;替换了,如何做?
- web程序中怎样用飞信啊?
- 动态设置div高度的问题
- 帮忙看下,为何报错,说没有实例
- webbrowser控件怎么显示出来?
- 有谁可以给我提示以下csdn的smartclient专题链接是什么?
- datagrid的一个问题!
- 大家好,为什么对datagird的pagesize设置为14后,下面选中非第一页索引后,仍旧显示10条记录?如何为选中索引项变颜色。
- 除了cookie session,还有什么方法保存用户记录?
- 我给图片加了一个绝动地址链接,为什么点了不起反应
- 求助:找不到类型或命名空间名称“ConfigurationSettings”(是否缺少 using 指令或程序集引用?)
全局错误处理程序,优先于在 Web.config customErrors 元素的 defaultRedirect 属性中指定的错误处理。