我似乎已经完美地设置了我的自定义错误(根据我访问过的所有文章)。
发生异常时,我被带到客户404或500页。
但是,调试时HandleErrorInfo模型对象始终为null。
有什么我想念的吗?
Web.config:
<customErrors mode="On" defaultRedirect="~/Error/NotFound" redirectMode="ResponseRedirect">
<error statusCode="404" redirect="~/Error/NotFound" />
<error statusCode="500" redirect="~/Error/ServerError" />
</customErrors>
Error404.cshtml
@model System.Web.Mvc.HandleErrorInfo
@using AAKINS.HI.WEB.Helpers;
@{
ViewBag.Title = "Error";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="list-header clearfix" style="font-size: 30px !important; color:red">
404 Page Not Found
</div><br/>
<div style="font-size:18px; color:black">
An unexpected error has occurred. Please contact your system administrator.
</div>
@{
if (Model != null && HttpContext.Current.IsDebuggingEnabled)
{
<div>
<p>
<b>Exception:</b> @Model.Exception.Message<br />
<b></b> @Model.ControllerName<br />
<b></b> @Model.ActionName
</p>
<div style="overflow: scroll">
<pre>
@Model.Exception.StackTrace
</pre>
</div>
</div>
}
}