我已將我的網站上傳到Web服務器。我有一個選項可以上傳下載和刪除文件。我處於測試階段,一切進展順利。我嘗試上傳文件,我刪除了它,它完全可以工作。但是當我試圖刪除現有的文件時,它會拋出一個錯誤:無法刪除Web服務器中的現有文件
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
我知道它與權限有關。當我比較我通過網站上傳的文件中存在的權限時,它顯示.NET v4.5而在現有文件中,沒有這樣的用戶。我嘗試添加它,但沒有.NET v 4.5。
我試着添加網絡服務,並給了它完整的權限,但仍然沒有運氣。我希望你能幫助我這個人。
UPDATE:
這裏是異常的詳細信息:
System.UnauthorizedAccessException: Access to the path 'C:\"MyFilePath"' is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user. To grant ASP.NET access to a file, right-click the file in File Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
請問您能否添加異常詳細信息? – Boney
@Boney我在我的問題中添加了異常詳細信息。非常感謝。 – moonlight04
應用程序池運行時的標識應該對正試圖刪除的文件具有刪除權限。 您可以讓我知道該網站運行的AppPool的身份嗎? 嘗試將AppPool更改爲「ASP.NET v4.0集成」並授予組「IIS_IUSRS」對該文件夾的訪問權限。 – Boney