Asp.net

即使使用 customErrors=‘Off’(在 ubuntu/mono 上),Web.config 也不會遠端顯示錯誤

  • May 19, 2016

這是我的 Web.config 文件:

<?xml version="1.0"?>
<configuration>
   <system.web>
       <customErrors mode="Off" />    
       <compilation debug="true" strict="false" explicit="true />    
       <pages>
         <namespaces>
           <clear />
           <add namespace="System" />
           <add namespace="System.Collections" />
           <add namespace="System.Collections.Generic" />
           <add namespace="System.Collections.Specialized" />
           <add namespace="System.Configuration" />
           <add namespace="System.Text" />
           <add namespace="System.Text.RegularExpressions" />
           <add namespace="System.Web" />
           <add namespace="System.Web.Caching" />
           <add namespace="System.Web.SessionState" />
           <add namespace="System.Web.Security" />
           <add namespace="System.Web.Profile" />
           <add namespace="System.Web.UI" />
           <add namespace="System.Web.UI.WebControls" />
           <add namespace="System.Web.UI.WebControls.WebParts" />
           <add namespace="System.Web.UI.HtmlControls" />
         </namespaces>
         <controls>
           <add src ="~/controls/maleBed.ascx" tagPrefix ="mycontrol" tagName ="male"/>
           <add src ="~/controls/femaleBed.ascx" tagPrefix ="mycontrol" tagName ="female"/>
         </controls>
       </pages>
   </system.web>
</configuration>

即使將 customErrors 模式設置為 Off(並且它肯定是大寫的“O”),它仍然向我顯示預設錯誤頁面,告訴我在遠端看到實際錯誤之前設置此屬性。

我沒有 machine.config 文件,我還在 Web.Debug.config 和 Web.Release.config 中設置了這個 customErrors mode=“Off”。

有什麼想法嗎?

非常感謝。

編輯 - 它的顯示:

Server Error in '/' Application

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File -->

<configuration>
   <system.web>
       <customErrors mode="Off"/>
   </system.web>
</configuration>


Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File -->

<configuration>
   <system.web>
       <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
   </system.web>
</configuration>

<compilation debug="true" strict="false" explicit="true />

在您的程式碼中是錯誤的。這裡更正:(見最後一個引號)

<compilation debug="true" strict="false" explicit="true" />

我發現在更改 web.config 文件後我實際上必須重新啟動 apache ……

引用自:https://stackoverflow.com/questions/5043339