无法读取配置节'customErrors',因为它缺少节声明

时间:2012-02-12 15:37:03

标签: c# asp.net web-config

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

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

  

无法读取配置部分'customErrors',因为它是   错过了部分声明。

我已经尝试了所有可能性,但我仍然遇到上述错误。任何人都可以建议我应该在配置文件中更改哪些内容来解决问题?

我的Webconfig文件:

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

1 个答案:

答案 0 :(得分:20)

<CustomErrors>位于<system.web>之下。您直接在<configuration>下拥有自己的<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> 。也就是说,customErrors标记的父元素是配置,这是不正确的。检查MSDN on customErrors将显示将其添加到配置文件的正确结构。

{{1}}
相关问题