c# - Setting Server Bindings of IIS 6.0 Programmatically -


i'm trying set installer register web site. currently, i've got creating application pool , web site under windows server 2003. unfortunately, whenever try modify serverbindings property set ip address, throws exception @ me. first tried because documentation here told me http://msdn.microsoft.com/en-us/library/ms525712%28vs.90%29.aspx. i'm using vb.net, c# answers okay need switch on using c# anyway.

siterootde.properties.item("serverbindings").item(0) = "<address>" 

this throws argumentoutofrangeexception. checked it, , server bindings of size 0. when tried create new entry in list this:

siterootde.properties.item("serverbindings").add("<address>") 

i comexception when try that.

i looked @ registered property keys, , serverbindings found. however, when create web site through iis, generates serverbindings correctly , can see it.

what need serverbindings appear?

edit: moved code on c# , tried it. seems reason, vb.net crashes when given either above, c# doesn't. code still doesn't seem anything. silently fails. i'm trying this:

// webpage folder created website directoryentry siterootde = new directoryroot("iis://localhost/w3svc/webpage"); // www.mydomain.com 1 of ip addresses shows // when used iis administrative program siterootde.properties["serverbindings"].value = ":80:www.mydomain.com"; siterootde.commitchanges(); 

in c# should able this:

website.invoke("put", "serverbindings", ":80:www.mydomain.com");  

or

website.properties["serverbindings"].value = ":80:www.mydomain.com"; 

edit:

here sample code used.

public static void createnewwebsite(string siteid, string hostname) {     directoryentry webservice = new directoryentry("iis://localhost/w3svc");      directoryentry website = new directoryentry();     website = webservice.children.add(siteid, "iiswebserver");     website.commitchanges();      website.invoke("put", "serverbindings", ":80:" + hostname);     // or website.properties["serverbindings"].value = ":80:" + hostname;                 website.properties["serverstate"].value = 2;     website.properties["servercomment"].value = hostname;     website.commitchanges();      directoryentry rootdir = website.children.add("root", "iiswebvirtualdir");     rootdir.commitchanges();      rootdir.properties["appisolated"].value = 2;     rootdir.properties["path"].value = @"c:\inetpub\wwwroot\myrootdir";     rootdir.properties["authflags"].value = 5;     rootdir.properties["accessflags"].value = 513;     rootdir.commitchanges();     website.commitchanges();     webservice.commitchanges(); } 

also, here article reference.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -