I have a web application where I need to retrieve the user's my documents folder path. I can get it fine using this command while running the process from VS 2017:
But when I have deployed it to IIS and run the process through IE it is giving me the local folder on the sharepoint server where I have the web app. What commands do I need to retrieve the same information through IIS?
It is not possible to get the user's MyDocuments from a web server. It works while developing as your system is both the server and the client and the server's MyDocuments are your MyDocuments.
We couldn't directly visit users Documents or users memory in our application.If it is possible , it means we get any files of other computers and we could make changes in any files in their computers.That is obviously not secure for users. You could visit
yout computer because the visit is your local machine.You have the rights to set the folder or program.
All your C# code runs on the web server which doesn't have any access to the client side. The purpose of this server side code is to render an HTML page which is shiown in the browser. The browser is itself a sandbox with very limited access to local resource
for safety reason.
In short the standard way for a web server to access a client side file is to let the user upload this (and for safety reason the input type=file upload control can be populated only by the user).
It's common to be confused when starting as you usually develop on a machine that is both the web server and the browser side machine which can give the impression things that won't ever work with a real web server could work.
Member
4 Points
66 Posts
Retrieiving user my documents folder path
Apr 17, 2019 08:23 PM|baldwinjohn|LINK
I have a web application where I need to retrieve the user's my documents folder path. I can get it fine using this command while running the process from VS 2017:
exportfolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
But when I have deployed it to IIS and run the process through IE it is giving me the local folder on the sharepoint server where I have the web app. What commands do I need to retrieve the same information through IIS?
Thanks.
All-Star
53051 Points
23634 Posts
Re: Retrieiving user my documents folder path
Apr 17, 2019 08:31 PM|mgebhard|LINK
It is not possible to get the user's MyDocuments from a web server. It works while developing as your system is both the server and the client and the server's MyDocuments are your MyDocuments.
Participant
1300 Points
522 Posts
Re: Retrieiving user my documents folder path
Apr 18, 2019 03:01 AM|Wei Zhang|LINK
Hi baldwinjohn,
We couldn't directly visit users Documents or users memory in our application.If it is possible , it means we get any files of other computers and we could make changes in any files in their computers.That is obviously not secure for users. You could visit yout computer because the visit is your local machine.You have the rights to set the folder or program.
Best Regards
Wei
All-Star
48530 Points
18075 Posts
Re: Retrieiving user my documents folder path
Apr 19, 2019 01:49 PM|PatriceSc|LINK
Hi,
All your C# code runs on the web server which doesn't have any access to the client side. The purpose of this server side code is to render an HTML page which is shiown in the browser. The browser is itself a sandbox with very limited access to local resource for safety reason.
In short the standard way for a web server to access a client side file is to let the user upload this (and for safety reason the input type=file upload control can be populated only by the user).
It's common to be confused when starting as you usually develop on a machine that is both the web server and the browser side machine which can give the impression things that won't ever work with a real web server could work.