【问题标题】:Practicing web.config and getting error练习 web.config 并出现错误
【发布时间】:2013-11-09 19:24:54
【问题描述】:

我正在练习来自hereweb.config文件
当我复制并粘贴以下代码时:

<configSections>
  <section name ="ProductSection" type ="<ProductSection" />
</configSections>

<ProductSection>
<gridSettings title ="Latest Products" count ="20"></gridSettings>
<color background="FFFFCC" foreground="FFFFFF"></color>
</ProductSection>

我遇到了几个错误,例如:

  • 标签未在第二行关闭。
  • &lt;/section&gt; 不见了。
  • 命名空间'section' 不能包含子元素。

如何去除这些错误并顺利运行。

【问题讨论】:

  • 在stackoverflow上提问之前应该自我评估一下,这不是一个好问题,可以通过谷歌搜索和理解问题来解决。
  • @Haider:我是 .net 的新手,花了一段时间才来的。

标签: c# asp.net .net


【解决方案1】:

代替

<section name ="ProductSection" type ="<ProductSection" />

试试

<section name ="ProductSection" type ="&lt;ProductSection" />

Which are the HTML, and XML, special characters?

【讨论】:

  • 谢谢帮助。它解决了这个问题,但它说“为 ProductSection 创建配置节处理程序时出错:无法加载类型'
  • @Sohail:您可能还有其他类似的问题,即可能需要转义的其他字符。检查我的答案中的链接。
【解决方案2】:

你有这个:

type ="<ProductSection"

这在XML中无效,去掉“

<section name ="ProductSection" type ="ProductSection" />

如果您确实有带有“

<section name ="ProductSection" type ="&lt;ProductSection" />

但是,由于实际部分是 &lt;ProductSection&gt;,这可能只是您的拼写错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-31
    • 2011-09-27
    • 1970-01-01
    • 1970-01-01
    • 2017-04-25
    相关资源
    最近更新 更多