I'm using the File Upload control. It works perfect on my own/local/devleopment machine, but when I publish the web pages to my web host and run the file upload page, I get the following error after clicking my File Upload button.
Access to the path 'D:\inetpub\mywebfolder\subfoldername\filename' 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.
---
I don't want to grant write access to the file. I just want to allow the user to upload the file to us, and the user shouldn't have to set any file properties/permissions to upload the file.
the problem is that ASPNET user or NETWORK SERVICE user (both are user accounts on the server, which ASPNET uses to authorize for the OS) need to have permissions to write the file to aforementioned location.
Account need the permissions to the folder where file is written (the file isn't there before uploading, of course), so user of course doesn't set any permissions to anywhere but server admninistrator does to
'D:\inetpub\mywebfolder\subfoldername dir in this case (I might suggest specifying a location outside web folders in case they are not supposed to be downloaded just like that)
Writing something is stronger permission than just reading so, admin needs to give the write permission in order to enable file uploading if you want to save it straight to server's hard disk.
When I'm uploading the file I'm getting the following error
Can you please help me?
Access to the path 'D:\Inetpub\vhosts\thecoutureworks.com\httpdocs\administrator\Upload\Thumb\back.bmp' is denied.Access to the path 'D:\Inetpub\vhosts\thecoutureworks.com\httpdocs\administrator\Upload\Thumb\back.bmp' is denied.
Thanks
Please give us feedback no matter whether you get your answer.
I got the same error message. Check if the properties of folder uncheck readonly in General tab. In security Tab give write control for Network Service. Hope this would work
I got the same error message. Check if the properties of folder uncheck readonly in General tab. In security Tab give write control for Network Service. Hope this would work
You might use the source bellow,which is very good to copy file across different servers and
websites(Note that it is a modified code that i use,So you might need to recorrect the syntax )
Dont be shy to investigate me on this code and ask me questions
Best Luck:
String CompleteFTPPath =
path of the ip adressString CompleteLocalPath =
path of the local file
String UName =
the user name you use to enter the ftp
String PWD =
the password you use to enter the ftp
vtsnowrider
Member
47 Points
16 Posts
ASP.NET 2.0 File Upload - Access to Path is Denied
Apr 21, 2006 11:01 PM|LINK
Hi,
I'm using the File Upload control. It works perfect on my own/local/devleopment machine, but when I publish the web pages to my web host and run the file upload page, I get the following error after clicking my File Upload button.
Access to the path 'D:\inetpub\mywebfolder\subfoldername\filename' 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.
---
I don't want to grant write access to the file. I just want to allow the user to upload the file to us, and the user shouldn't have to set any file properties/permissions to upload the file.
Any ideas?
joteke
All-Star
46284 Points
6896 Posts
ASPInsiders
MVP
Re: ASP.NET 2.0 File Upload - Access to Path is Denied
Apr 22, 2006 05:27 AM|LINK
Hi,
the problem is that ASPNET user or NETWORK SERVICE user (both are user accounts on the server, which ASPNET uses to authorize for the OS) need to have permissions to write the file to aforementioned location.
Account need the permissions to the folder where file is written (the file isn't there before uploading, of course), so user of course doesn't set any permissions to anywhere but server admninistrator does to 'D:\inetpub\mywebfolder\subfoldername dir in this case (I might suggest specifying a location outside web folders in case they are not supposed to be downloaded just like that)
Writing something is stronger permission than just reading so, admin needs to give the write permission in order to enable file uploading if you want to save it straight to server's hard disk.
Teemu Keiski
Finland, EU
riyazakt
Member
268 Points
59 Posts
Re: ASP.NET 2.0 File Upload - Access to Path is Denied
Jul 16, 2008 11:50 AM|LINK
Hi,
When I'm uploading the file I'm getting the following error
Can you please help me?
Access to the path 'D:\Inetpub\vhosts\thecoutureworks.com\httpdocs\administrator\Upload\Thumb\back.bmp' is denied.Access to the path 'D:\Inetpub\vhosts\thecoutureworks.com\httpdocs\administrator\Upload\Thumb\back.bmp' is denied.
Thanks
Regards,
Riyaz
nideeshm
Participant
1069 Points
269 Posts
Re: ASP.NET 2.0 File Upload - Access to Path is Denied
Jul 16, 2008 11:59 AM|LINK
Nideesh.S
Mark as answer, If it helps you.
nideeshm
Participant
1069 Points
269 Posts
Re: ASP.NET 2.0 File Upload - Access to Path is Denied
Jul 16, 2008 11:59 AM|LINK
Nideesh.S
Mark as answer, If it helps you.
sumitd
Star
12168 Points
2151 Posts
Re: ASP.NET 2.0 File Upload - Access to Path is Denied
Jul 16, 2008 04:56 PM|LINK
Download FileMon tool from the below URL
http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx
Run FileMon on the server, where upload folder exists and let it execute, Now run the application try to upload the file.
Stop FileMon and save it in Excel file.
Open excel and add filter in the permission the column and check with Access Denied.
You might get lots of access denied of different files, Try to get the access denied of your application
Visit: www.msblogdirectory.com
www.dotnetspeaks.com
riyazakt
Member
268 Points
59 Posts
Re: ASP.NET 2.0 File Upload - Access to Path is Denied
Jul 17, 2008 05:46 AM|LINK
thanks for your reply.
if it is the problem of access denied then how i can upload file from FTP.
Regards,
Riyaz
talg
Member
144 Points
73 Posts
Re: ASP.NET 2.0 File Upload - Access to Path is Denied
Jul 17, 2008 07:37 AM|LINK
Hi ,
You might use the source bellow,which is very good to copy file across different servers and
websites(Note that it is a modified code that i use,So you might need to recorrect the syntax )
Dont be shy to investigate me on this code and ask me questions
Best Luck:
String CompleteFTPPath = path of the ip adressString CompleteLocalPath = path of the local file String UName = the user name you use to enter the ftp String PWD = the password you use to enter the ftp
PFile.SaveAs(fName);uploadFileUsingFTP(CompleteFTPPath, CompleteLocalPath , UName , PWD );
public void uploadFileUsingFTP(String CompleteFTPPath, String CompleteLocalPath, String UName, String PWD){
System.Net.FtpWebRequest request = (System.Net.FtpWebRequest)System.Net.FtpWebRequest.Create(CompleteFTPPath);request.Method = System.Net.
WebRequestMethods.Ftp.UploadFile; request.Credentials = new System.Net.NetworkCredential(UName, PWD);request.UsePassive =
true; request.UseBinary = true;request.KeepAlive = false;
FileStream stream = File.OpenRead(CompleteLocalPath); byte[] buffer = new byte[stream.Length];stream.Read(buffer, 0, buffer.Length);
stream.Close();
Stream reqStream = request.GetRequestStream();reqStream.Write(buffer, 0, buffer.Length);
reqStream.Close();
}
DB & GUI Developer
Israel,tel aviv
talg
Member
144 Points
73 Posts
Re: ASP.NET 2.0 File Upload - Access to Path is Denied
Jul 17, 2008 07:42 AM|LINK
Hi again,
And by the way i am waremly reccomanding to check the iis log ,Im sure you will find
some important additional information like the user tring to access, the deny resoan etc'
You might want to use the tool that was mention before or manualy check the log file
Tal
DB & GUI Developer
Israel,tel aviv
NomanZafar
Member
8 Points
13 Posts
Re: ASP.NET 2.0 File Upload - Access to Path is Denied
Jun 28, 2009 06:19 AM|LINK
I got the same problem, but by giving network services write error to specific folder, solved my problem