我查看了一堆其他问题,寻找详细错误页面布局的绝佳示例,但没有找到任何东西。我相信很多人以前都做过这个。
要求 * 必须显示异常信息(类型、堆栈跟踪) * 应尽可能显示表单值 * 应显示导致问题的区域/控制器/操作
我想出的最好的是:
@model System.Web.Mvc.HandleErrorInfo
@{ViewBag.Title = "Error";}
<h2>Sorry, an error occurred while processing your request.</h2>
<p>Please copy and paste this entire page in an email to
<a href="mailto:me@me.com?subject=Website%20Error">Me</a>
along with any other information you can provide so we can
get this fixed ASAP!</p>
@if (Model != null) {
<h1>@Model.Exception.GetType().Name<br />
thrown in @Model.ControllerName @Model.ActionName</h1>
<h2>Details</h2>
<div>
@Model.Exception.ToString()
</div>
}