我使用自定义错误页面设置
<customErrors mode="On" defaultRedirect="~/Home/Error">
<error statusCode="404" redirect="~/Home/PageNotFound" />
</customErrors>
Run Code Online (Sandbox Code Playgroud)
我创建了一个抛出异常的页面,然后重定向到正确的错误页面.
但是我注意到生产网络服务器上的elmah中的这些错误:
System.InvalidOperationException未找到视图"错误"或其主文件或视图引擎不支持搜索的位置.搜索了以下位置:〜/ Areas/Football/Views/Draft/Error.aspx~/Areas/Football/Views/Draft/Error.ascx~/Areas/Football/Views/Shared/Error.aspx~/Areas/Football /Views/Shared/Error.ascx~/ Views/Draft/Error.aspx~/Views/Draft/Error.ascx~/Views/Shared/Error.aspx~/Views/Shared/Error.ascx~/Areas/Football /意见/ Draft/Error.cshtml~/Areas/Football/Views/Draft/Error.vbhtml~/Areas/Football/Views/Shared/Error.cshtml~/Areas/Football/Views/Shared/Error.vbhtml~/Views/Draft/Error.cshtml~/Views/Draft/Error.vbhtml~/Views/Shared/Error.cshtml~/Views/Shared/Error.vbhtml
为什么要在别处寻找错误页面?我删除了〜/ Views/Shared/Error.cshtml并在〜/ Home/Error中添加了我的自定义错误页面,因为我在配置文件中指定了一个新的默认值.
有任何想法吗?
谢谢.