首页 新闻 会员 周边

如何通过代码部署IIS,在线等

0
悬赏园豆:15 [已解决问题] 解决于 2014-07-30 23:40

想通过代码来部署IIS,但是老是报拒绝访问的错误,可能是权限问题,但是不知道该怎么改,代码如下

 string wwwroot = "c:\\Inetpub\\wwwroot";
            string virtualDirectoryName = "myNewApp";
            string sitepath = "IIS://localhost/W3SVC/1/ROOT";

            DirectoryEntry vRoot = new DirectoryEntry(sitepath);
            DirectoryEntry vDir = vRoot.Children.Add(virtualDirectoryName,
                                        "IIsWebVirtualDir");
            vDir.CommitChanges();

            vDir.Properties["Path"].Value = wwwroot + "\\" + virtualDirectoryName;
            vDir.Properties["DefaultDoc"].Value = "Default.aspx";
            vDir.Properties["DirBrowseFlags"].Value = 2147483648;
            vDir.CommitChanges();
            vRoot.CommitChanges();
DirectoryEntry vRoot = new DirectoryEntry(sitepath);
vRoot中报 拒绝访问的错误:System.Runtime.InteropServices.COMException: 拒绝访问。

求解!!!
Peter_youny的主页 Peter_youny | 初学一级 | 园豆:80
提问于:2013-06-14 17:53
< >
分享
最佳答案
1

添加此目录everyone、aspnet用户权限

收获园豆:15
二十三号同学 | 小虾三级 |园豆:974 | 2013-06-14 18:32
其他回答(1)
0

权限问题!

小花晋 | 园豆:202 (菜鸟二级) | 2013-06-14 23:06
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册