When I run the ASP.Net application using the FileUpload to copy a file located in my local workstation and saving it in my local C:\ drive everything works fine.
But when I run the same application and try to FileUpload the same file to a location in a server in another machine I get the following error message:
“Access \\server\\folder\\file.txt to the path denied.”
The folder on the server has to give write permissions to the Network Service user account or it will never work. Also make sure that the aspnet user has write permissions to the folder too :)
This would be a local account on the web server itself. Right click the folder, click Properties. Go to Permissions and look at the list of users there. Make sure the Network Service user is listed there. If not, add it and give it write permissions.
Ok, on the IIS Server where you are putting these files, you perform this same thing but instead click Add, specify the machine, not the AD, then find it in the list of users. heres' a link to help you do that:
You mentioned that "The app and the server are in different machines. FileUpload1.SaveAs("\\server\\shares\\folder\\" & _
FileUpload1.FileName)
Did you make sure network service has permissions on the folder you are saving to? You might have to configure the path as a web folder since its possible that shared folder has NT permissions on it. You might also want to try using impersonation for this
purpose.
Yes for testing purposes the web applicaiton and the IIS are in my workstation and the folder to upload the files is on another computer a server.
When the application will be deployed to production the applicaiton will be on a server and the data stored on another server.
To your question Did you make sure network service has permissions on the folder you are saving to? I am able to copy a file with windows explorer from my workstation to the server, so my account can write on the server.
Questions:
How do you configure the path as a web folder?
If I use impersonation, is there anything else I need to do add on the code? May be the account to access the server?
jsn1
Participant
985 Points
322 Posts
FileUpload Access \\server\\folder\\file.txt to the path denied.
Mar 16, 2012 06:26 PM|LINK
Hi all,
I am currently testing a web form to upload documents to a specific folder on a server in the network following this sample http://msdn.microsoft.com/en-us/library/aa479405.aspx
When I run the ASP.Net application using the FileUpload to copy a file located in my local workstation and saving it in my local C:\ drive everything works fine.
But when I run the same application and try to FileUpload the same file to a location in a server in another machine I get the following error message:
“Access \\server\\folder\\file.txt to the path denied.”
The app and the server are in different machines.
FileUpload1.SaveAs("\\server\\shares\\folder\\" & _
FileUpload1.FileName)
My guess is that it is a very common problem related to permissions with IIS, but I do not know how to solve it
bbcompent1
All-Star
32978 Points
8502 Posts
Moderator
Re: FileUpload Access \\server\\folder\\file.txt to the path denied.
Mar 16, 2012 06:27 PM|LINK
The folder on the server has to give write permissions to the Network Service user account or it will never work. Also make sure that the aspnet user has write permissions to the folder too :)
jsn1
Participant
985 Points
322 Posts
Re: FileUpload Access \\server\\folder\\file.txt to the path denied.
Mar 16, 2012 06:28 PM|LINK
What is the "Network Service user account "? How can I find it?
My account belongs to an active directory group, and I can copy files using Windows Explorer to the server from my workstation.
Is there another account used by IIS?
bbcompent1
All-Star
32978 Points
8502 Posts
Moderator
Re: FileUpload Access \\server\\folder\\file.txt to the path denied.
Mar 16, 2012 06:32 PM|LINK
This would be a local account on the web server itself. Right click the folder, click Properties. Go to Permissions and look at the list of users there. Make sure the Network Service user is listed there. If not, add it and give it write permissions.
jsn1
Participant
985 Points
322 Posts
Re: FileUpload Access \\server\\folder\\file.txt to the path denied.
Mar 16, 2012 06:37 PM|LINK
I just checked, there are the following accounts:
Also The IIS is installed in my workstation, and the folder where files are copied is located in a server in another computer.
How can I find the Network Service user ?
If it is local account on the web server itself, how can I authorize my network account to write on the folder on the server?
bbcompent1
All-Star
32978 Points
8502 Posts
Moderator
Re: FileUpload Access \\server\\folder\\file.txt to the path denied.
Mar 16, 2012 06:40 PM|LINK
Ok, on the IIS Server where you are putting these files, you perform this same thing but instead click Add, specify the machine, not the AD, then find it in the list of users. heres' a link to help you do that:
http://support.microsoft.com/kb/870668
bbcompent1
All-Star
32978 Points
8502 Posts
Moderator
Re: FileUpload Access \\server\\folder\\file.txt to the path denied.
Mar 16, 2012 06:41 PM|LINK
Go through steps 1 - 5 but don't forget to add Write. I know its referring to Reporing Services but the concept is still the same.
jsn1
Participant
985 Points
322 Posts
Re: FileUpload Access \\server\\folder\\file.txt to the path denied.
Mar 16, 2012 08:19 PM|LINK
I tried the Nework Account and even changing Everyone to full control it does not work.
Any other ideas?
bbcompent1
All-Star
32978 Points
8502 Posts
Moderator
Re: FileUpload Access \\server\\folder\\file.txt to the path denied.
Mar 16, 2012 08:21 PM|LINK
You mentioned that "The app and the server are in different machines. FileUpload1.SaveAs("\\server\\shares\\folder\\" & _
FileUpload1.FileName)
Did you make sure network service has permissions on the folder you are saving to? You might have to configure the path as a web folder since its possible that shared folder has NT permissions on it. You might also want to try using impersonation for this purpose.
jsn1
Participant
985 Points
322 Posts
Re: FileUpload Access \\server\\folder\\file.txt to the path denied.
Mar 16, 2012 09:44 PM|LINK
Hi
Yes for testing purposes the web applicaiton and the IIS are in my workstation and the folder to upload the files is on another computer a server.
When the application will be deployed to production the applicaiton will be on a server and the data stored on another server.
To your question Did you make sure network service has permissions on the folder you are saving to? I am able to copy a file with windows explorer from my workstation to the server, so my account can write on the server.
Questions:
Please advise