host headers c# add programmatically

Discussion in 'ASP .Net' started by greg, Dec 21, 2004.

  1. greg

    greg Guest

    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
     
    greg, Dec 21, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Karl Easterly
    Replies:
    3
    Views:
    391
    Karl Easterly
    Aug 20, 2003
  2. Tim_Mac
    Replies:
    3
    Views:
    1,021
    Elton Wang
    Apr 1, 2005
  3. dont bother
    Replies:
    0
    Views:
    865
    dont bother
    Mar 3, 2004
  4. Phil
    Replies:
    4
    Views:
    730
    Gabriel Genellina
    Jan 17, 2010
  5. Ian
    Replies:
    2
    Views:
    2,099
Loading...

Share This Page