【问题标题】:The configuration section 'customErrors' cannot be read because it is missing a section declaration无法读取配置部分“customErrors”,因为它缺少部分声明
【发布时间】:2012-02-12 15:37:03
【问题描述】:

我已将我的网页上传到服务器。

我的网页在本地系统中运行良好。但是当我将它上传到服务器时,它显示错误

无法读取配置部分“customErrors”,因为它是 缺少部分声明。

我已经尝试了所有可能性,但仍然出现上述错误。谁能建议我应该在我的配置文件中更改什么来解决这个问题?

我的网络配置文件:

<configuration>
    <configSections>
        <section name="neatUpload" type="Brettle.Web.NeatUpload.ConfigSectionHandler, Brettle.Web.NeatUpload" allowLocation="true" />
        <sectionGroup name="modulesSection">
            <section name="rewriteModule" type="RewriteModule.RewriteModuleSectionHandler, RewriteModule" />
        </sectionGroup>
    </configSections>
    <!-- <customErrors mode="ON" /> -->
    <!--  <customErrors mode="Off" />  -->
    <customErrors mode="ON" defaultRedirect="GenericErrorPage.html">
         <!--   <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" /> -->
    </customErrors>
    <modulesSection>
        <rewriteModule>
            <rewriteOn>true</rewriteOn>
            <rewriteRules>
            <rule source="http://[^/]*/*(\w+[&amp;-]*\w+)/*((\w+[&amp;-]*\w+)(\s)*)*/*((\w+[&amp;-]*\w+)(\s)*)*$" destination="landPage.aspx?CampaginName=$1&amp;SubDomain=$2&amp;UserName=$3&amp;PageName=$4" />
            <!-- <rule source=".*" destination="landPage.aspx?CampaginName=$1&amp;UserName=$2"/>-->
            </rewriteRules>
        </rewriteModule>
    </modulesSection>

【问题讨论】:

    标签: c# asp.net web-config


    【解决方案1】:

    &lt;CustomErrors&gt; 位于&lt;system.web&gt; 下,您的&lt;configuration&gt; 下直接。也就是说,您的 customErrors 标签的父元素是配置,这是不正确的。检查MSDN on customErrors 将向您显示正确的结构,以将其添加到您的配置文件中。

    <configuration>
        <!-- your other stuff -->
        <system.web>
            <customErrors mode="ON" defaultRedirect="GenericErrorPage.html">
                 <!--   <error statusCode="403" redirect="NoAccess.htm" />
                <error statusCode="404" redirect="FileNotFound.htm" /> -->
            </customErrors>
        </system.web>
    </configuration>
    

    【讨论】:

    • 感谢您的回复。执行此操作后,它显示“无法识别的元素'system.web'”错误
    • 我愿意打赌你的 system.web 嵌套在另一个部分中,或者在顶部 configSections 之前。确保 &lt;system.web&gt; 出现在您的 &lt;/modulesSection&gt; 之后
    猜你喜欢
    • 2011-09-16
    • 2013-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多