问题
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