我已经给了IUSR完全控制文件夹但是当我上传文件时它给了我这个错误: 访问路径'C:\ inetpub \ wwwroot \ vivaweb \ usr_up_img \ Desert.jpg'被拒绝。 描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪,以获取有关错误及其在代码中的起源位置的更多信息。
Exception Details: System.UnauthorizedAccessException: Access to the path 'C:\inetpub\wwwroot\vivaweb\usr_up_img\Desert.jpg' 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) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, 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 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.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
Stack Trace:
[UnauthorizedAccessException: Access to the path 'C:\inetpub\wwwroot\vivaweb\usr_up_img\Desert.jpg' is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +7716783
System.IO.File.Delete(String path) +7577512
ASP.vivaweb_dwzupload_resizeaspnet_aspx.ResizeImage(String oldPathImage, String newPathImage, Int32 Width, Int32 Height, Int32 imgQuality, Boolean keep, Boolean isThumb) +217
ASP.vivaweb_dwzupload_resizeaspnet_aspx.Page_Load(Object sender, EventArgs e) +379
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
答案 0 :(得分:0)
很明显,您的应用程序正在使用“ASP.NET”用户
因此,请允许此用户或仅向用户所有人
授予权限答案 1 :(得分:0)
这篇文章中有一些未解答的问题,我必须做出一些假设。首先,我不知道您如何部署您的网站,因此不知道它使用的是什么身份。如果您直接通过visual studio运行它,根据您的版本,它应该使用"ApplicationPoolIdenity" or "NetworkService"。
如果您通过IIS运行您的站点,您可以轻松地解决这个问题(如果您愿意,可以更改它)。只需在IIS实例下打开应用程序池,您就应该在&#34;身份和#34;中看到它们。列。
之后,您需要确保授予与您网站使用的身份相同的权限。获取用于存放网站的根文件夹并为其提供适当的权限。右键单击该文件夹,然后转到属性 - &gt;安全 - &gt;编辑。添加您的网站正在使用的标识,您应该完成。
最后一点,如果您在本地/调试环境中,实际上可能需要打开web.config文件中的调试配置设置。它将提供更多信息来解决您的问题。