Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code to create IIS Website

Tags:

iis

iis-7

I need to programatically create an IIS website. Can anybody show me the code to do this?

like image 370
Bob Jones Avatar asked Feb 01 '26 17:02

Bob Jones


1 Answers

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);
like image 110
Carlos Aguilar Mares Avatar answered Feb 04 '26 15:02

Carlos Aguilar Mares



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!