Web.config isn't showing errors remotely even

2019-06-16 16:16发布

问题:

Here is my Web.config file:

<?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>

Even with customErrors mode set to Off (and its definitely a capital "O") its still showing me the default errors page telling me to set this property before I can see that actual error remotely.

I don't have a machine.config file, and I've also set this customErrors mode="Off" in the Web.Debug.config and the Web.Release.config.

Any ideas anyone?

Thank you very much.

Edit - what its showing:

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>

回答1:

The Line

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

in your code is wrong. Here the correction: (see the last quotation mark)

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


回答2:

I found that I actually had to restart apache after making changes to the web.config file...



回答3:

Couldn't find an answer - we had to get Windows based hosting.



回答4:

Those settings look correct to me.

Are you positive you're looking at the right web.config file? Are you overriding any of these values in your page directive(s)?

Consider posting your whole web.config (sans private info).

EDIT: Also, what is it showing when you view the page?



回答5:

Although I am getting really frustrated with Mono over the past 2 days and considering myself getting windows hosting I found out that at least for MVC 4 web sites in order to get detailed errors you have to go in Views and find the Web.config there and add the required directive <customErrors mode="Off"/>.

Adding it in the Web.config found in the main directory does not change a thing.

Then the real trouble begins.



回答6:

I did have the some problem. I am also pretty new to linux. In my case, the problem was that I have not added the required permissions to the site folder and a result, the Web.config was not even read.

Just for debug, you could try allow full permissions for all to the entire site folder (recursively).

  • chmod -R ugo+rwx /your_site_root

It is not recommended though to go to production with such permissions.