如何继续standart Asp.net Mvc-应用程序错误页面

本文关键字:Mvc- net 应用程序 错误 Asp standart 何继续 继续 | 更新日期: 2024-09-24 06:45:17

如果我的mvc应用程序在发布模式(发布模式)下运行,我会处理所有错误消息

但当我在调试模式下工作时,我看不到standartmvc应用程序错误页面。

因为它正在重定向到位于共享文件夹中的Error.cshtml。

我怎样才能看到(或者重定向?)standart 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>

如何继续standart Asp.net Mvc-应用程序错误页面

MVC 4默认支持使用HandleError属性处理错误,将您重定向到error.cshtml.

只需使用customErrors mode="off" 更新web.config