Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET .NET
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 2-May-11 6:01am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  
Comments
Albin Abel at 3-May-11 6:33am
   
Informative link. My 5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Rahul_Patel at 2-May-11 11:15am
   
How???????????????????
   
You could start with google.
jim lahey at 2-May-11 11:18am
   
Again, it's in the error message. Have you even read it?
   
5 - Proposed as answer
RaviRanjankr at 2-May-11 11:20am
   
Nice, My vote of 5 :)
Manfred R. Bihy at 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 at 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 at 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 at 2-May-11 13:41pm
   
@Manfred R. Bihy
Now as u may hv noticed smtimes wht looks obvious is not always correct.....
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Reading what you posted in your question would help:
 
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
  Permalink  
Comments
jim lahey at 2-May-11 11:19am
   
Have my 5.
Rahul_Patel at 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 at 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)

  Print Answers RSS
0 Maciej Los 424
1 ridoy 400
2 DamithSL 230
3 OriginalGriff 179
4 Suvendu Shekhar Giri 150
0 OriginalGriff 8,033
1 DamithSL 6,179
2 Sergey Alexandrovich Kryukov 5,538
3 Maciej Los 5,508
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 3 May 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100