用.NET在IIS中创建虚拟目录

使用.NET的目录服务就可以访问IIS的设置,添加虚拟目录其实就是创建一个DirectoryEntry
复杂的在于DirectoryEntry的属性,其实就是虚拟目的一些配置,比如,权限,是否要log,应用程序名等
Properties非常多,而且文档不太好找
详细可以参考MSDN以下内容
help://MS.MSDNQTR.2004JUL.1033/iissdk/iis/configuring_properties_in_the_iis_user_interface.htm

代码示例:

   const String constIISWebSiteRoot = "IIS://localhost/W3SVC/1/ROOT";

   DirectoryEntry root = new DirectoryEntry(constIISWebSiteRoot);
   DirectoryEntry entry = new DirectoryEntry(constIISWebSiteRoot + "/" + virtualDirName);

   DirectoryEntry tbEntry = root.Children.Add(virtualDirName, "IIsWebVirtualDir");

   //must be end with a '/'
   tbEntry.Properties["Path"][0] = virtualDirPath;
   tbEntry.Invoke("AppCreate",true);
   tbEntry.Properties["AccessRead"][0] = true;
   tbEntry.Properties["ContentIndexed"][0] = false;
   tbEntry.Properties["DefaultDoc"][0] = "index.asp";
   tbEntry.Properties["AppFriendlyName"][0] = virtualDirName;
   tbEntry.Properties["AppIsolated"][0] = 2;
   tbEntry.Properties["AccessScript"][0] = true;   
   tbEntry.Properties["DontLog"][0] = true;   
   
   tbEntry.CommitChanges();

发表于 Friday, November 05, 2004 4:46 PM

href="http://blog.joycode.com/yaodong/Services/Pingback.aspx" rel="pingback"/>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值