Scott
We have used structure like this:
string WebConfigFileName =
Server.MapPath(Request.Url.AbsolutePath).ToLower().Replace("default.aspx","web.config");
System.Xml.XmlDocument objDoc = new System.Xml.XmlDocument();
objDoc.Load(WebConfigFileName);
System.Xml.XmlNode objHttpModules = objDoc.DocumentElement["system.web"]["httpModules"];
bool Exists = false;
foreach(System.Xml.XmlNode objNode in objHttpModules.ChildNodes)
{
if(objNode.Attributes!=null)
{
if(objNode.Attributes["name"]!=null)
{
if(objNode.Attributes["name"].Value=="OurName")
{
Exists = true;
break;
}
}
}
}
if(!Exists)
{
System.Xml.XmlNode objAdd = objDoc.CreateElement("add");
System.Xml.XmlAttribute objName = objDoc.CreateAttribute("name");
objName.Value = "OurName";
System.Xml.XmlAttribute objType = objDoc.CreateAttribute("type");
objType.Value = "OurValue";
objAdd.Attributes.Append(objName);
objAdd.Attributes.Append(objType);
objHttpModules.AppendChild(objAdd);
try
{
objDoc.Save(WebConfigFileName);
}
catch(Exception Exc)
{
DotNetNuke.Skin.AddModuleMessage(this,"web.config updates error "+Exc.Message,
DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError);
}
}
Hope it helps.
Sergey