用于创建IIS网站的代码 [英] Code to create IIS Website
本文介绍了用于创建IIS网站的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要以编程方式创建一个IIS网站。有人可以告诉我这样做的代码吗?
I need to programatically create an IIS website. Can anybody show me the code to do this?
推荐答案
请不要使用WMI( DirectoryEntry
)如果可能的话,定位IIS 7或更高版本。有一个名为的API Microsoft.Web.Administration.dll
中的 ServerManager
( windows \ system32\inetsrv
)这使得这很容易:
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);
这篇关于用于创建IIS网站的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文