I need to programatically create an IIS website. Can anybody show me the code to do this?
Please don't use WMI (DirectoryEntry) if at all possible when targeting IIS 7 or above. There is an API called ServerManager in the Microsoft.Web.Administration.dll (windows\system32\inetsrv) that makes this really easy:
ServerManager serverManager = new ServerManager();
serverManager.Sites.Add("Mysite", "c:\temp\", 8080);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With