【发布时间】:2013-12-14 18:05:40
【问题描述】:
如果我的 mvc 应用程序在发布模式(发布模式)下运行,我会处理所有错误消息
但是当我在调试模式下工作时,我看不到标准 mvc 应用程序错误页面。
因为它重定向到位于共享文件夹中的 Error.cshtml。
我怎样才能看到(或重定向?)标准 mvc 错误页面?
protected void Application_Error()
{
// ReSharper disable once RedundantAssignment
// ReSharper disable once ConvertToConstant.Local
bool isCustomErrorEnabled = false;
--#if(!DEBUG) isCustomErrorEnabled = true; --#endif
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
if (isCustomErrorEnabled) //Context.IsCustomErrorEnabled
{
ShowCustomErrorPage(Server.GetLastError());
}
else
{
//in this line, I want to continue to show standart
// application error page which has error message and stack trace
}
}
更新 - 这是我的 Web.Config 文件;
<system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<globalization uiCulture="auto" culture="auto" />
<customErrors defaultRedirect="/Home/OldLink" mode="On" redirectMode="ResponseRewrite">
<!-- RemoteOnly : Specifies that custom errors are shown only to the remote clients, and that ASP.NET errors are shown to the local host. This is the default value. -->
</customErrors>
【问题讨论】:
-
查看 webconfig 并搜索自定义错误模式
-
拉梅什,谢谢您的回答。但是我通过代码中的“#if(!DEBUG)”忽略了app.config中的那一行......
标签: c# asp.net-mvc asp.net-mvc-5