G
greg
we need to add host headers to a IIS site (not default one)
in .NET/c#
we can print host headers but cannot insert programmatically new one
bellow is our code
DirectoryEntry TemplSite = new DirectoryEntry("IIS://LocalHost/w3svc/6");
if (TemplSite.SchemaClassName == "IIsWebServer")
{
Console.WriteLine(TemplSite.Name);
Console.WriteLine(TemplSite.Properties["ServerComment"].Value.ToString());
object[] hosts = (object[])TemplSite.Properties["ServerBindings"].Value;
foreach(string host in hosts)
{
Console.WriteLine(host);
}
///// DOES NOT WORK
ArrayList hostsList = new ArrayList(hosts);
hostsList.Add(":80:qqqqqq2.com");
object[] newhosts = hostsList.ToArray();
TemplSite.Properties["ServerBindings"].Value = (object)newhosts;
}
Thanks
GSL
in .NET/c#
we can print host headers but cannot insert programmatically new one
bellow is our code
DirectoryEntry TemplSite = new DirectoryEntry("IIS://LocalHost/w3svc/6");
if (TemplSite.SchemaClassName == "IIsWebServer")
{
Console.WriteLine(TemplSite.Name);
Console.WriteLine(TemplSite.Properties["ServerComment"].Value.ToString());
object[] hosts = (object[])TemplSite.Properties["ServerBindings"].Value;
foreach(string host in hosts)
{
Console.WriteLine(host);
}
///// DOES NOT WORK
ArrayList hostsList = new ArrayList(hosts);
hostsList.Add(":80:qqqqqq2.com");
object[] newhosts = hostsList.ToArray();
TemplSite.Properties["ServerBindings"].Value = (object)newhosts;
}
Thanks
GSL