configurationelement

Loading a ConfigurationSection with a required child ConfigurationElement with .Net configuration framework

烈酒焚心 提交于 2019-12-22 03:32:28
问题 I have a console application that is trying to load a CustomConfigurationSection from a web.config file. The custom configuration section has a custom configuration element that is required. This means that when I load the config section, I expect to see an exception if that config element is not present in the config. The problem is that the .NET framework seems to be completely ignoring the isRequired attribute. So when I load the config section, I just creates an instance of the custom

How to revert an HttpError ConfigurationElement back to “Inherited” using IIS 7 API

别等时光非礼了梦想. 提交于 2019-12-08 16:00:36
问题 Suppose I have the following <httpErrors> collection in a web.config : <httpErrors> </httpErrors> Yep, nice 'n empty. And in IIS 7, my HTTP errors page looks like this: Beautiful! (I've highlighted 404 simply because that's the example I'll use in a sec). Now, I run the following code: errorElement["statusCode"] = 404; errorElement["subStatusCode"] = -1; errorElement["path"] = "/404.html"; httpErrorsCollection.Add(errorElement); Lovely. I now have, as expected this in my web.config :

How do I use .NET custom ConfigurationElement properties on descendent elements?

醉酒当歌 提交于 2019-12-01 04:21:40
How can I get and use an attribute set in the parent ConfigurationSection in the descendent CustomSetting element? I need this attribute when the CustomSetting element is returning the Value property. I want to format the App.config like this: <CustomSettings someProperty="foo"> <CustomSetting key="bar" value="fermeneba" /> <CustomSetting key="laa" value="jubaduba" /> </CustomSettings> I have the code working, except that I cannot find a way to access the someProperty attribute from the CustomSetting class. The only way that I've found, so far, is to format the configuration like this, which

How do I use .NET custom ConfigurationElement properties on descendent elements?

我怕爱的太早我们不能终老 提交于 2019-12-01 02:29:09
问题 How can I get and use an attribute set in the parent ConfigurationSection in the descendent CustomSetting element? I need this attribute when the CustomSetting element is returning the Value property. I want to format the App.config like this: <CustomSettings someProperty="foo"> <CustomSetting key="bar" value="fermeneba" /> <CustomSetting key="laa" value="jubaduba" /> </CustomSettings> I have the code working, except that I cannot find a way to access the someProperty attribute from the