视图异常未显示MVC 3 Custom/Http错误页面

Mar*_*nHN 6 asp.net-mvc-3

我在ASP.NET MVC 3应用程序中设置了自定义/ http错误,将在错误时显示.我Web.ConfighttpErrors部分看起来像这样:

    <httpErrors errorMode="Custom" existingResponse="Replace">
        <remove statusCode="400" />
        <remove statusCode="403" />
        <remove statusCode="404" />
        <remove statusCode="408" />
        <remove statusCode="500" />
        <remove statusCode="503" />
        <error statusCode="400" responseMode="ExecuteURL" path="/Error/BadRequest" />
        <error statusCode="403" responseMode="ExecuteURL" path="/Error/Forbidden" />
        <error statusCode="404" responseMode="ExecuteURL" path="/Error/NotFound" />
        <error statusCode="408" responseMode="ExecuteURL" path="/Error/Timeout" />
        <error statusCode="500" responseMode="ExecuteURL" path="/Error/InternalServerError" />
        <error statusCode="503" responseMode="ExecuteURL" path="/Error/ServiceUnavailable" />
    </httpErrors>
Run Code Online (Sandbox Code Playgroud)

我没有设置customerErrors设置,因为这对MVC和IIS 7.5不起作用.

当代码中发生异常时,一切正常.

但是,当在视图中抛出异常时 - 它会尝试显示~/Views/Shared/Error.cshtml我没有的默认值.

可能抛出错误的视图可能是这样的:

@Html.Partial("TemplateSection", Model.PreContent)
Run Code Online (Sandbox Code Playgroud)

并且想象PreContent为null,并且TemplateSection通过执行以下操作显示值时视图将失败:@Model.Name