想通过代码来部署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: 拒绝访问。
求解!!!
添加此目录everyone、aspnet用户权限
权限问题!