interdev_programming thread: Allowing users to download files.
If you're working in an intranet environment, then you might consider
allowing the users to retrieve the documents using the "File" protocol in
your hyperlink as opposed to the HTTP protocol. The URL might look like
this...
Assuming they have a Mapped Drive (M:) to the server:
File:\\M:\ShareName\Path\To\File.ext
Or using a UNC path (no mapping required):
\\ServerName\ShareName\Path\To\File.ext
Both of these solutions assume you are working on a Microsoft OS on the
client, Neither solution requires the web server (no virtual root issues),
but note that the UNC approach won't work with Netscape. This is only
feasible in an Intranet environment when the user has shared access to the
server.
BUT, your question is specifically regarding virtual paths... so here is
the bottom line:
A user can't retrieve a file using HTTP unless the file exists within a
directory that has Web Sharing turned on. By adding files to your web
project, you are effectively copying those files into a directory that is
being served by your web application.
Creating an HTTP web address to "open any file in a directory somewhere on
the server" will only work if the directory in question has been
configured as a virtual root (web sharing turned on). This doesn't need
to be the same virtual root as your web applicatoin (asp files), but it
does need to exist within the IIS settings. Permissions are something you
may need to deal with as well (by default, everyone has full control... so
it shouldn't be a problem at first).
Here's what I recommend... Assign a specific directory on your server as
the storage location for all files that are uploaded and retrieved. Let's
call this the "library" folder.
1) Using Internet Services Manager (IIS), create a new virtual root to
serve the contents of the Library folder independent from your web App.
You could also visit the Library folder using Windows Explorer on the
server, right mouse click -> Properties -> Web Sharing Tab, turn on "Share
this Folder". Assign a name for the virtual root like "VirtualLibrary".
2) Train your users to upload files only into the Library folder, and/or
some sub-directory thereof.
3) Either way, the path to your uploaded files will look similiar to:
http://ServerName/VirtualLibrary/Path/To/File.ext
while your web application might still look like:
http://ServerName/WebApplication/file.asp
Good luck,
Jim M.
> Hello,
> I am using Interdev and mainly ASP pages. I want to place links on a
page
> that when clicked open various files such as PDFs, txt, doc, etc.
> I am confused about how the virtual root directory works. I can create a
> standard html <a href=... but that only works on files I have manually
> placed into the web project.
> I need to be able to open any file in a directory somewhere on the
server
> because the sites contents will be dynamic. The pages with the links are
> dynamic and are constructed from a database, so the user can acces files
> that they originally uploaded to our server.
>
> Thanks,
> Mike