ASP.NET CustomError Handling in MasterPage Error Page

假装没事ソ 提交于 2020-01-06 05:07:49

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/4509827/asp-net-customerror-handling-in-masterpage-error-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!