Programmatically create a web site in IIS using C# and set port number -


we have been able create web site. did using information in link:

https://msdn.microsoft.com/en-us/library/ms525598.aspx

however, use port number other port 80. how this?

we using iis 6

if you're using iis 7, there new managed api called microsoft.web.administration

an example above blog post:

servermanager iismanager = new servermanager(); iismanager.sites.add("newsite", "http", "*:8080:", "d:\\mysite"); iismanager.commitchanges();  

if you're using iis 6 , want this, it's more complex unfortunately.

you have create web service on every server, web service handles creation of website because direct user impersonation on network won't work (if recall correctly).

you have use interop services , similar (this example uses 2 objects, server , site, instances of custom classes store server's , site's configuration):

string metabasepath = "iis://" + server.computername + "/w3svc"; directoryentry w3svc = new directoryentry(metabasepath, server.username, server.password);  string serverbindings = ":80:" + site.hostname; string homedirectory = server.wwwrootpath + "\\" + site.foldername;   object[] newsite = new object[] { site.name, new object[] { serverbindings }, homedirectory };  object websiteid = (object)w3svc.invoke("createnewsite", newsite);  // returns website id metabase int id = (int)websiteid; 

see more here


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -