Click here to Skip to main content
15,306,032 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Whnevr i try to upload a file using ma browser i get the following error.. Please help.. I noe its coz of low privileges of asp.net account bt how to resolve the problem...

Server Error in '/Translator' Application.
Access to the path 'E:\My Documents\Visual Studio 2008\Translator\App_Data' 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:\My Documents\Visual Studio 2008\Translator\App_Data' 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: 

Line 76:     protected void Button2_Click(object sender, EventArgs e)
Line 77:     {
Line 78:         FileUpload1.SaveAs(Server.MapPath("App_Data"));
Line 79:     }
Line 80: }
Source File: e:\My Documents\Visual Studio 2008\Translator\Default.aspx.cs    Line: 78 
Posted

Adding to above:
When you are uploading a file to the server, you need to have appropriate write permission to the account processing the request on the directory that you are using to upload the file.

Check the MSDN link - FileUpload Control Security Considerations section[^]

Either provide the write permission to the user (generally ASPNET user) or to the user account that is impersonating the calls.
   
Comments
Albin Abel 3-May-11 6:33am
   
Informative link. My 5
You can resolve the problem by granting the application pool identity write and create permissions on App_Data. Just like the error message states, incidentally.
   
Comments
Rahul_Patel 2-May-11 11:15am
   
How???????????????????
#realJSOP 2-May-11 11:16am
   
You could start with google.
jim lahey 2-May-11 11:18am
   
Again, it's in the error message. Have you even read it?
#realJSOP 2-May-11 11:15am
   
5 - Proposed as answer
RaviRanjanKr 2-May-11 11:20am
   
Nice, My vote of 5 :)
Manfred Rudolf Bihy 2-May-11 11:28am
   
@Jim: Yup, take my 5+!
@The univoter: Stating the obvious doesn't sit well with everbody I guess!
Rahul_Patel 2-May-11 13:40pm
   
I think people here were busy distributing their 5's that they din even care to c the syntactical error....

The statement should have been
FileUpload1.SaveAs(System.IO.Path.Combine(Server.MapPath("App_Data"),FileUpload1.FileName));
rather than
FileUpload1.SaveAs(Server.MapPath("App_Data"));
jim lahey 3-May-11 4:00am
   
Well why didn't you post that in the first place then?

We can only go by what people post in their questions, and as far as I am aware, mind reading has nothing to do with this site.
Rahul_Patel 2-May-11 13:41pm
   
@Manfred R. Bihy
Now as u may hv noticed smtimes wht looks obvious is not always correct.....
Reading what you posted in your question would help:

XML
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:


Now which part of that do you not understand?

Best Regards,

-MRB
   
Comments
jim lahey 2-May-11 11:19am
   
Have my 5.
Rahul_Patel 2-May-11 13:40pm
   
I think people here were busy distributing their 5's that they din even care to c the syntactical error....

The statement should have been
FileUpload1.SaveAs(System.IO.Path.Combine(Server.MapPath("App_Data"),FileUpload1.FileName));
rather than
FileUpload1.SaveAs(Server.MapPath("App_Data"));
yesotaso 2-May-11 15:36pm
   
Result: You made a mistake and brought the obvious here. They saw 11 lines of error trying to tell you that the ASP.NET does not have permisson on "App_Data".

Irrelevance: I gave 5 to Mr. Manfred just for being handsome...

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