如何继续使用标准版Asp.net Mvc - 应用程序错误页面

时间:2022-06-22 03:30:56

I handled all error messages if my mvc application running in Release Mode ( Publish mode )

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

But when I'm working in debug mode, I can't see standart mvc application error page.

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

Because it's redirecting to Error.cshtml which is located in shared folder.

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

How can I see(or redirect maybe?) standart mvc error page ?

我怎样才能看到(或重定向?)标准mvc错误页面?

    protected void Application_Error()
    {
        // ReSharper disable once RedundantAssignment
        // ReSharper disable once ConvertToConstant.Local
        bool isCustomErrorEnabled = false;

--#if(!DEBUG) isCustomErrorEnabled = true; --#endif

- #if(!DEBUG)isCustomErrorEnabled = true; - #万一

        // 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
        }

    }

UPDATE - Here is my Web.Config file;

更新 - 这是我的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>

1 个解决方案

#1


0  

MVC 4 Default support to handle error with HandleError attribute is redirecting you to Error.cshtml.

MVC 4使用HandleError属性处理错误的默认支持是将您重定向到Error.cshtml。

Just update your web.config with customErrors mode="off"

只需使用customErrors mode =“off”更新您的web.config

#1


0  

MVC 4 Default support to handle error with HandleError attribute is redirecting you to Error.cshtml.

MVC 4使用HandleError属性处理错误的默认支持是将您重定向到Error.cshtml。

Just update your web.config with customErrors mode="off"

只需使用customErrors mode =“off”更新您的web.config