https://blog.csdn.net/a497785609/article/details/49952281
寫了一個類IISAdmin,負責建立、設置、刪除虛擬目錄,發現在web中調用,遇到權限問題,解決方法如下(轉載):
下面代碼在ASP.NET中,會因權限問題被拒絕訪問。
以下為引用的內容: System.DirectoryServices.DirectoryEntry directoryEntry; directoryEntry = new System.DirectoryServices.DirectoryEntry("IIS://localhost/w3svc/1"); directoryEntry.Invoke("Start", new object[] { }); 錯誤:拒絕訪問。 異常詳細信息: System.UnauthorizedAccessException: 拒絕訪問。 解決方法 修改web.config文件 <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.web> <identity impersonate="true" userName="administrator" password="1q2w3e4r"/> </system.web> </configuration> |
在ASP.NET里面使用COM對象的時候,會被拒絕訪問。
可以在web.config里面添加下面代碼解決
以下為引用的內容: |