1) If ( inside web.config file ) I declare custom section named songPoem before <configSection>
, an error is reported saying songPoem element is not recognized. Thus, the following gives me an error:
<songPoem song=”lalala” />
<configSection>
<section name=”songPoem” type=”A” />
</configSection>
while the following works just fine:
<configSection>
<section name=”songPoem” type=”A” />
</configSection>
<songPoem song=”lalala” />
A) I assume error is due to .Net reading web.config
from top to bottom?! If so, is the order of element declaration an issue only when it comes to custom section elements, or...?
BTW - here's the definition for class A:
public class A: ConfigurationSection
{
[ConfigurationProperty(“song”)]
public string Song{ ... }
}
2) I would assume that only song attribute would be allowed inside <songPoem>
element, and thus I would expect that .Net would be able to notice if custom section element includes any non existing attributes. But for some reason I was able to include other attributes also, even though they don’t map to any property of class A:
<songPoem song=”lalala” movie=”this_should_be_here” />
Any idea why Net didn't notice that songPoem contains an invalid attribute?