c# - 无法读取配置部分 'customErrors',因为它缺少部分声明

标签 c# asp.net web-config

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

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

The configuration section 'customErrors' cannot be read because it is missing a section declaration.

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

我的网络配置文件:

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

最佳答案

<CustomErrors>属于 <system.web>你有你的 <configuration>直接地。也就是说,您的 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>

关于c# - 无法读取配置部分 'customErrors',因为它缺少部分声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9250029/

相关文章:

asp.net - 在 Azure 管道发布期间替换 Web.config 中的连接字符串

c# - 我应该在每次交易后关闭套接字(TCPIP)吗?

c# - Wpf 数据网格滚动条卡住

c# - 使用数组填充列表框?

azure - azure linux 应用服务上未添加缓存控制 header

asp.net - 关于 web.config 的官方、广泛、完整的文档在哪里?

c# - WCF SSL 客户端证书错误

c# - 使用StreamReader复制图像时损坏

javascript - 将文本上传到 javascript 中的 asp.net 通用处理程序

asp.net - 从 asp.net 发送电子邮件时,SMTP 服务器需要安全连接或客户端未通过身份验证错误