Click here to Skip to main content
15,905,967 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted
Comments
[no name] 6-May-13 16:09pm    
The error message is perfectly clear and tells you what/how to do to correct the issue. So, what is your question?
ZurdoDev 6-May-13 16:14pm    
What's the question? It's a permissions issue, as the error states.
Sergey Alexandrovich Kryukov 6-May-13 16:24pm    
This is amazing! You show exception information in detail but no code sample. Others should only the code fragment, without exception information of compilation errors. Does anyone here understand that's it's important to provide both?!

—SA

1 solution

Well, Im going to put my head out there and say that it is some permissions issue no???? :)

Come on, without any code this is really not a question at all..

However, look at this:

http://netindonesia.net/blogs/haritianp/archive/2010/07/18/iis-7-application-pool-identities-access-is-denied-to-directory.aspx[^]

Basically, your asp.net website app pool should run under a dedicated account or at least the defaultapppool user. Grant permissions on that folder and you should be away!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900