MasterPage 错误页面中的 ASP.NET CustomError 处理

发布于 2024-10-08 22:28:09 字数 592 浏览 0 评论 0原文

我将错误重定向到 Error.aspx

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

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

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

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

这里有问题:

示例:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寄与心 2024-10-15 22:28:09

如果您使用 web.config 进行自动重定向,我想说您应该有一个非常简单的错误页面,几乎不可能出现服务器错误。如果您正在该页面上访问数据库,并且错误与此相关,您将进入循环。

另一种选择是使用 global.asax 上的错误处理程序重定向到错误页面。这将涉及 C# 逻辑。在那里,您可以检测错误是否是在 error.aspx 上生成的,在这种情况下,您可以重定向到 fatalerror.aspx(例如,仅显示一条消息的白色页面)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文