If you have ever tried creating a website in IIS 6.0 by using WMI object model you would know that it is not easiest thing to do. There was no native support from IIS object model, IIS 7.0 has much improved Application Programming Interface (API) set , it quite simpler and straight forward.
Microsoft.Web.Administration is name space which contains majority of server objects, it also provides a convenient way of manipulating configuration files including AdministrationHost File, All APIs in IIS 7.0 object model are managed code.
Here is code listing to create a simple HelloWorld site (You need to add reference to Microsoft.Web.Administration namespace, it usually located at C:\Windows\System32\inetsrv
Creating a website, application pool and application
ServerManager serverMgr = new ServerManager();
//Create website
Site mySite = serverMgr.Sites.Add("HelloWorld",@"C:\inetpub\wwwroot\HelloWorld", 9292);
//Create application pool
serverMgr.ApplicationPools.Add("HelloWorld");
//Create application
mySite.Applications.Add("HelloWorldApplication");
//assign application pool to site
mySite.Applications["HelloWorldApplication"].ApplicationPoolName = "HelloWorld";
mySite.ServerAutoStart = true;
serverMgr.CommitChanges();
more to follow....
1 comment:
Hello
My wife Sadaf Shah just passed away. I would like to make a website in her memory as she was a very charitable person and helped a lot of people. I'd be extremely grateful if you could please give me back the domain as you are not using it. Her profile is https://www.linkedin.com/in/sadafshah1
You can reach me on asadushah@gmail.com
Kind regards
Asad
Post a Comment