Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# IIS Server ASP.NET4.0
hi
When I want upload a file with fileUpload Control in asp.net I get this error on server .
the server use plesk interface.
 

 

Server Error in '/' Application.
 
Access to the path '~\Upload\NewsImage' 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 '~\Upload\NewsImage' 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: 
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
 
Stack Trace: 
 

[UnauthorizedAccessException: Access to the path '~\Upload\NewsImage' is denied.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +9726046
   System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj) +9497018
   System.IO.Directory.CreateDirectory(String path) +146
   GUI.AddNews.btnSave_Click(Object sender, EventArgs e) in D:\My Project\AzadUniv\New\55\GUI\AddNews.aspx.cs:59
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   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.1
Posted 5-Sep-12 10:06am
Edited 5-Sep-12 10:34am
Wes Aday94.3K
v2
Comments
Wes Aday at 5-Sep-12 15:35pm
   
Screaming and rudeness removed.
Kenneth Haugland at 5-Sep-12 15:51pm
   
Desparation removed is proberbly also a thing....
Wes Aday at 5-Sep-12 15:54pm
   
That too but then I would have to type more letters... :-)
Kenneth Haugland at 5-Sep-12 16:54pm
   
Its quite amazing what people ask questions about here... Like we are the oracle of delphi or something like it...

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The solution comes from your own error message:
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.
 
Also, here[^], let me Google it for you.
 
Behnam Mohammadi wrote:
IT'S VERY VERY URGENT PLEASE HELP ME

Now this, we do not like. It may be urgent to everyone and anyone posting a question, but these forums are run by volunteers providing answers in their own free time, trying to help others. No-one gets priority over anyone, no matter how urgentz their issue may be. For this reason, I've downvoted your question
  Permalink  
Comments
Wes Aday at 5-Sep-12 15:34pm
   
Nice
Behnam Mohammadi at 5-Sep-12 15:37pm
   
i can't use iis i user plesk interface and now the site uploded to the server.
Andrei Straut at 5-Sep-12 15:43pm
   
So, you mean you have no access to the server? Then you how do you upload your sources to it?
 
If you have no access to the server to modify the file permissions yourself, then you might speak to your hosting company to grant you the access rights you need
Behnam Mohammadi at 5-Sep-12 15:53pm
   
I have SERVER
I don't know use ISS
my server interface is plesk
this code is path on my computer but i don't know how run in the server GUI.AddNews.btnSave_Click(Object sender, EventArgs e) in D:\My Project\AzadUniv\New\55\GUI\AddNews.aspx.cs:59
i thin the probleem it is.

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

  Print Answers RSS
0 OriginalGriff 7,645
1 DamithSL 5,614
2 Sergey Alexandrovich Kryukov 5,344
3 Maciej Los 4,961
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 5 Sep 2012
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