0
我在我的web.config问题创建自定义配置节
<mySectionGroup>
<sectionOneSection>
<page path="~/123.aspx"></page>
<page path="~/456.aspx"></page>
</sectionOneSection>
</mySectionGroup>
以下XML和下面的代码
public class SectionOneSection : ConfigurationSection {
[ConfigurationProperty("sectionOne")]
public PageConfigurationCollection Pages {
get {
return this["sectionOne"] as PageConfigurationCollection;
}
}
public static SectionOneSection GetConfig() {
return ConfigurationManager.GetSection("mySectionGroup/sectionOneSection") as
SectionOneSection;
}
}
public class PageElement : ConfigurationElement {
[ConfigurationProperty("path", IsRequired = true)]
public string Path {
get {
return this["path"].ToString();
}
set {
this["path"] = value;
}
}
}
public class PageConfigurationCollection : ConfigurationElementCollection {
public PageElement this[int index] {
get {
return base.BaseGet(index) as PageElement;
}
set {
if (base.BaseGet(index) != null) {
base.BaseRemoveAt(index);
}
this.BaseAdd(index, value);
}
}
protected override string ElementName {
get {
return base.ElementName;
}
}
protected override ConfigurationElement CreateNewElement() {
return new PageElement();
}
protected override object GetElementKey(ConfigurationElement element) {
return ((PageElement)element).Path;
}
}
我也得到尝试检索时出现以下错误该部分
无法识别的元素“页面”。 (C:\ app \ web.config第39行)
我在这里丢失了什么?