无法删除 Web 服务器中的现有文件
Cannot Delete Existing File in Web Server
我已经将我的网站上传到网络服务器。我可以选择上传下载和删除文件。我正在测试中,一切进展顺利。我尝试上传一个文件,我删除了它并且它完全有效。但是当我试图删除现有文件时,它会抛出一个错误:
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。
我尝试添加 NETWORK SERVICE 并授予它完全权限,但仍然没有成功。我希望你们能在这方面帮助我。
更新:
异常详情如下:
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.
运行应用程序池的身份应对其尝试删除的文件具有删除权限。
尝试将 AppPool 更改为 'ASP.NET v4.0 Integrated' 并授予组 'IIS_IUSRS' 访问该文件夹的权限。
我已经将我的网站上传到网络服务器。我可以选择上传下载和删除文件。我正在测试中,一切进展顺利。我尝试上传一个文件,我删除了它并且它完全有效。但是当我试图删除现有文件时,它会抛出一个错误:
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。
我尝试添加 NETWORK SERVICE 并授予它完全权限,但仍然没有成功。我希望你们能在这方面帮助我。
更新:
异常详情如下:
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.
运行应用程序池的身份应对其尝试删除的文件具有删除权限。
尝试将 AppPool 更改为 'ASP.NET v4.0 Integrated' 并授予组 'IIS_IUSRS' 访问该文件夹的权限。