> Some options to look at:
>
[quoted text clipped - 4 lines]
> Ken
>
Thanks for your reply Ken, I have actually been looking at
Microsoft.Web.Administration.
I wrote a little test program, which would allow me to modify various
options within the appplicationHost.config file:
using System;
using Microsoft.Web.Administration;
namespace WebATest1 {
internal class Program {
private static void Main(string[] args) {
ServerManager serverManager =
ServerManager.OpenRemote("194.46.4.8");
Configuration config =
serverManager.GetApplicationHostConfiguration();
// This works Perfectly
ConfigurationSection section =
config.GetSection("system.webServer/asp");
ConfigurationElement element =
section.GetChildElement("session");
Console.Write("allowSessionState attribute value: ");
Console.WriteLine(element.GetAttributeValue("allowSessionState"));
Console.WriteLine("Set allowSessionState value to true");
element.SetAttributeValue("allowSessionState", true);
serverManager.CommitChanges();
Console.Write("allowSessionState attribute value: ");
Console.WriteLine(element.GetAttributeValue("allowSessionState"));
section = null;
element = null;
// However this part doesnt
section = config.GetSection("system.webServer/");
element = section.GetChildElement("enableKernelCache");
Console.Write("enableKernelCache enabled value: ");
Console.WriteLine(element.GetAttributeValue("enableKernelCache"));
Console.WriteLine("Set enabled value to false ");
element.SetAttributeValue("enableKernelCache", false);
serverManager.CommitChanges();
Console.ReadLine();
}
}
}
The first part works perfectly, however the second part of the program
doesn't.
the applicationHost.config file section in question looks like:
<system.webServer>
<asp>
<cache
diskTemplateCacheDirectory="%SystemDrive%\inetpub\temp\ASP Compiled
Templates" />
<session allowSessionState="true" />
</asp>
<caching enabled="true" enableKernelCache="true">
</caching>
<cgi />
....
....
.....
......
</system.webServer>
Also I can not find any information on adding elements using the above
method.

Signature
Mick Walker
Software Engineer
http://www.mick-walker.co.uk
Ken Schaefer - 31 Oct 2007 13:52 GMT
I am not so familiar with using managed code, but I'll try to repro your
problem
When you say "it doesn't work", what do you mean exactly? nothing changes?
you get an error? etc
Cheers
Ken
>> Some options to look at:
>>
[quoted text clipped - 84 lines]
> Also I can not find any information on adding elements using the above
> method.