Jeffrey Palermo (.com)

Sponsors

The Lounge

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
EASY, EASY custom web.config section - level 200

Some people my shy away from this, but see how easy it is.  You need a block of custom xml as configuration, so you create your own .xml file and read it in.  Instead, use the web.config file.  It's already there, and it's good to keep all configuration in one place.  This is all it takes to make your own Configuration Handler class:

public class Config : IConfigurationSectionHandler {

//stores authorization xml from .config file

protected static XmlNode m_oXmlSection;

public static XmlNode XmlSection{

get { return m_oXmlSection; }

}

public object Create(object parent, object configContext, XmlNode section) {

m_oXmlSection = section.FirstChild;

return section.InnerXml;

}

}

Then, you just access Config.XmlSection, and you have the complete Xml, so why wouldn't you do it this way?


Posted 11-05-2004 1:35 PM by Jeffrey Palermo

[Advertisement]