views:

95

answers:

3

I want to enable the users of my website to download the files from the server, but I can do it only with those files which are inside the website's folder(by creating hyperlinks to those files).

How to enable the users to download files from server which are not in the website's folder but somewhere else on the server.

+3  A: 

Accessing files outside the website (its folder) is not safe. The server owner won't like to have that kind of a site running off the server. You should keep the filestore within the site.

Kangkan
@Kangkan: I also tried that but I faced 2 problems.First is that when i delete any file(which is inside site's folder) at runtime then all the session variables go away.Second, the number of files my be too large so I decided to keep files in a folder outside the site's folder.
Akshay
That should only happen if you're letting them delete web.config (or external config files referenced by it) or anything in the bin folder. The best place IMO for user files in an ASP.NET web app is in the App_Data folder.
jrummell
+5  A: 

Create a VirtualDirectory under your website in IIS. then you can point that VirtualDirectory to the other location that stores your files. Then to download them would be like: http://yoururl.com/YourVirtualDirectory/YourFile1.txt

The reason your session is dropping after some file modifications is the JIT is receiving a FileChangeNotifcation and attempting to recompile your website. Stick with the VirtualDirectory solution

used2could
+1  A: 

Deleting a folder within the website causes the .net web app to restart, you also lose all session variables.

To avoid this, just delete files only, or use this workaround:

http://www.aaronblake.co.uk/blog/2009/09/28/bug-fix-application-restarts-on-directory-delete-in-asp-net/

Aaron