本文介绍了asp.net项目出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

'/ ebook1''应用程序中的服务器错误。

拒绝访问路径''G:\ ebook1 \ picture''

说明:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。



异常详细信息:System.UnauthorizedAccessException:访问路径''G: \ ebook1 \ picture''被拒绝。



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帐户,并选中所需访问的框。



来源错误:





第32行:Response.Charset =;

第33行:Response.Cache.SetCacheability(HttpCacheability.NoCache);

行34:Response.WriteFile(picture);

第35行://Response.BinaryWrite((byte[])dr[\"data]);

Line 36:Response.End();





源文件:g:\ ebook1 \Downloadpdf.aspx.cs行:34



Stack Trace:





[UnauthorizedAccessException:访问路径''G:\ ebook1 \ picture''被拒绝。]

System.IO .__ Error.WinIOError(Int32 errorCode,String maybeFullPath)+10760710

系统。 IO.FileStream.Init(String path,FileMode mode,FileAccess access,Int32 rights,Boolean useRights,FileShare share,Int32 bufferSize,FileOptions o ptions,SECURITY_ATTRIBUTES secAttrs,String msgPath,Boolean bFromProxy,Boolean useLongPath,Boolean checkHost)+1352

System.IO.FileStream..ctor(String path,FileMode mode,FileAccess access,FileShare share)+65

System.Web.HttpResponse.WriteFile(String filename,Boolean readIntoMemory)+80

System.Web.HttpResponse.WriteFile(String filename)+18

Downloadpdf.GridView1_SelectedIndexChanged(Object sender,EventArgs e)在g:\ ebook1 \Downloadpdf.aspx.cs:34

System.Web.UI.WebControls.GridView.OnSelectedIndexChanged(EventArgs e )+116

System.Web.UI.WebControls.GridView.HandleSelect(Int32 rowIndex)+98

System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e ,Boolean causeValidation,String validationGroup)+213

System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument)+205

System.Web.UI.WebControls。 GridView.System.Web.UI.IPostBackEventHandl er.RaisePostBackEvent(String eventArgument)+13

System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,String eventArgument)+13

System.Web.UI.Page .RaisePostBackEvent(NameValueCollection postData)+9643314

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+1724





版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.17929

Server Error in ''/ebook1'' Application.
Access to the path ''G:\ebook1\picture'' 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 ''G:\ebook1\picture'' 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 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.

Source Error:


Line 32: Response.Charset = "";
Line 33: Response.Cache.SetCacheability(HttpCacheability.NoCache);
Line 34: Response.WriteFile("picture");
Line 35: //Response.BinaryWrite((byte[])dr["data"]);
Line 36: Response.End();


Source File: g:\ebook1\Downloadpdf.aspx.cs Line: 34

Stack Trace:


[UnauthorizedAccessException: Access to the path ''G:\ebook1\picture'' is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +10760710
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, Boolean checkHost) +1352
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +65
System.Web.HttpResponse.WriteFile(String filename, Boolean readIntoMemory) +80
System.Web.HttpResponse.WriteFile(String filename) +18
Downloadpdf.GridView1_SelectedIndexChanged(Object sender, EventArgs e) in g:\ebook1\Downloadpdf.aspx.cs:34
System.Web.UI.WebControls.GridView.OnSelectedIndexChanged(EventArgs e) +116
System.Web.UI.WebControls.GridView.HandleSelect(Int32 rowIndex) +98
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +213
System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +205
System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9643314
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929

推荐答案


这篇关于asp.net项目出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 17:18