0
我試圖從IIS網站內的目錄創建應用程序。基本上我想要做的是在代碼中重現此流程:右鍵單擊IIS網站中的文件夾,然後單擊以轉換爲應用程序。嘗試從代碼創建iis應用程序時拒絕訪問
這是我的代碼:
DirectoryEntry appsRoot = new DirectoryEntry("IIS://localhost/w3svc/3/Root");
//Create and setup new virtual directory
DirectoryEntry virtualDirectory = appsRoot.Children.Add(tool.Id.ToString(), "IIsWebVirtualDir");
virtualDirectory.Properties["Path"][0] = Path.Combine(AppConfig.ToolsFilePath, tool.Id.ToString());
virtualDirectory.Properties["AppFriendlyName"][0] = tool.Name;
virtualDirectory.CommitChanges();
// IIS6 - it will create a virtual directory
// IIS7 - it will create an application
virtualDirectory.Invoke("AppCreate", 1);
我得到的錯誤是訪問被拒絕。
Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).