练习web.config并收到错误

时间:2013-10-30 09:35:12

标签: c# asp.net .net

我正在here实施web.config个文件 当我复制并粘贴代码

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

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

我有几个错误,如:

  • 标签未在第二行关闭。
  • </section>丢失了。
  • 命名空间'section'不能包含子元素。

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

2 个答案:

答案 0 :(得分:6)

而不是

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

尝试

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

请参阅Which are the HTML, and XML, special characters?

答案 1 :(得分:1)

你有这个:

type ="<ProductSection"

这在XML中无效,摆脱了“&lt;”字符:

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

如果你真的有“&lt;”的东西,你必须像这样编码:

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

然而,因为实际部分是<ProductSection>,这可能只是你身边的一个错字。

相关问题