问题描述
我的错误是:
'/ WebSite5'应用程序中的服务器错误。
访问路径'E:\Program Files \ImageUp \WebSite5 \ Upload'被拒绝。
描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:System.UnauthorizedAccessException:访问路径'E:\\ \\ Prrogram Files \ImageUp \WebSite5 \ Upload'被拒绝。
ASP.NET无权访问所请求的资源。考虑将资源的访问权限授予ASP.NET请求标识。 ASP.NET具有基本进程标识(IIS 5上通常为{MACHINE} \ ASPNET,IIS 6和IIS 7上为网络服务,IIS 7.5上已配置的应用程序池标识),如果应用程序未模拟,则使用该标识。如果应用程序通过< identity impersonate =true>模拟,则身份将是匿名用户(通常是IUSR_MACHINENAME)或经过身份验证的请求用户。
要授予对文件的ASP.NET访问权限,请在资源管理器中右键单击该文件,选择属性,然后选择安全选项卡。单击添加以添加适当的用户或组。突出显示ASP.NET帐户,并选中所需访问的框。
来源错误:
第168行:Response.ContentType =application // octet-stream;
第169行:Response.AppendHeader(Content-Disposition,attachment; filename =+ fi.Name;
第170行:Response.TransmitFile(Server.MapPath(fi.Name));
第171行:Response.End();
第172行:}
源文件:e:\Program Files\ImageUp \ WebSite5 \Default.aspx.cs行:170
Stack Trace:
[UnauthorizedAccessException:访问路径'E:\Program Files \ ImageUp \WebSite5 \ Upload'被拒绝。]
System.IO .__ Error.WinIOError(Int32 errorCode ,String maybeFullPath)+9722910
System.IO.FileStream.Init(String p ath,FileMode模式,FileAccess访问,Int32权限,布尔useRights,FileShare共享,Int32 bufferSize,FileOptions选项,SECURITY_ATTRIBUTES secAttrs,字符串msgPath,布尔bFromProxy,布尔useLongPath)+1142
System.IO.FileStream ..ctor(String path,FileMode mode,FileAccess access,FileShare share)+83
System.Web.HttpResponse.TransmitFile(String filename,Int64 offset,int64 length)+132
System.Web.HttpResponse.TransmitFile(String filename)+15
_Default.lnkDownload_Click(Object sender,EventArgs e)在e:\Program Files \ImageUp \WebSite5 \Default .aspx.cs:170
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e)+118
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent (String eventArgument)+113
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)+9
System.Web .UI.Page.RaisePostBack Event(IPostBackEventHandler sourceControl,String eventArgument)+13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)+177
System.Web.UI.Page.ProcessRequestMain (Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+5563
版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.272
My Error was:
Server Error in '/WebSite5' Application.
Access to the path 'E:\Program Files\ImageUp\WebSite5\Upload' is denied.
Description: 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.
Exception Details: System.UnauthorizedAccessException: Access to the path 'E:\Program Files\ImageUp\WebSite5\Upload' 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 <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:
Line 168: Response.ContentType = "application//octet-stream";
Line 169: Response.AppendHeader("Content-Disposition", "attachment; filename=" + fi.Name);
Line 170: Response.TransmitFile(Server.MapPath(fi.Name));
Line 171: Response.End();
Line 172: }
Source File: e:\Program Files\ImageUp\WebSite5\Default.aspx.cs Line: 170
Stack Trace:
[UnauthorizedAccessException: Access to the path 'E:\Program Files\ImageUp\WebSite5\Upload' is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +9722910
System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath) +1142
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +83
System.Web.HttpResponse.TransmitFile(String filename, Int64 offset, Int64 length) +132
System.Web.HttpResponse.TransmitFile(String filename) +15
_Default.lnkDownload_Click(Object sender, EventArgs e) in e:\Program Files\ImageUp\WebSite5\Default.aspx.cs:170
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +118
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +113
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +9
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +176
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
推荐答案
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.
说...
希望这对您有帮助。
said...
Hope this will help you.
Response.ContentType = "application//octet-stream";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fi.Name);
Response.TransmitFile(Server.MapPath(fi.Name));
Response.End();
这篇关于访问路径拒绝错误...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!