ASP.NET CustomError处理MasterPage错误页面 [英] ASP.NET CustomError Handling in MasterPage Error Page

查看:195
本文介绍了ASP.NET CustomError处理MasterPage错误页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将错误重定向到Error.aspx

 < system.web> 
< customErrors defaultRedirect =error.aspxmode =On>
< error redirect =error.aspxstatusCode =500/>
< /system.web>

,问题是Error.aspx的ErrorMasterPage中还有第二个错误

 < script Language =C#MasterPageFile =〜/ ErrorMaster.Masterrunat =Server> 

和CustomError无法处理第二个错误,而它像一个循环(它将重定向到error.aspx和Error.aspx的主页有错误。



这里是问题:



示例:



Login.aspx(有错误) - > Error.aspx - > ErrorMasterPage.Master(有错误) - >显示黄页
谢谢

解决方案

如果你正在使用web.config自动重定向,我会说你应该有一个错误页面这么简单,几乎没有服务器错误是可能的,重新访问该页面上的数据库,如果错误与此相关,您将进入循环。



另一个选项将使用错误处理程序重定向到错误页面在global.asax上,这将涉及C#逻辑,您可以检测错误是否在error.aspx上生成,在这种情况下,您可以重定向到fatalerror.aspx(一个白页,仅显示一个消息) / p>

I redirect Errors to Error.aspx

 <system.web>
        <customErrors defaultRedirect="error.aspx" mode="On">
        <error redirect="error.aspx" statusCode="500" />
 </system.web>

and the problem is that there is also second error in ErrorMasterPage of Error.aspx

<script Language="C#" MasterPageFile="~/ErrorMaster.Master" runat="Server">

and CustomError can not handle the second error while its like a loop ( it will redirect to error.aspx and Masterpage of Error.aspx has Error.

here is problem:

Example:

Login.aspx(has Error) -> Error.aspx -> ErrorMasterPage.Master (has Error) -> Show Yellow Page Thanks

解决方案

If you're doing automatic redirection using web.config I'd say you should have an error page so simple that almost no server error is possible. If you're accessing the database on that page, you would enter on a loop if the error is related with that.

Another option would be redirecting to the error page using the error handler on global.asax. This would involve C# logic. There, you could detect if the error was generated on error.aspx and on that case, you could redirect to fatalerror.aspx (a white page just showing a message for instance).

这篇关于ASP.NET CustomError处理MasterPage错误页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆