naspinski
naspinski

Reputation: 34717

How can I hyperlink to a file that is not in my Web Application?

Ok, my web application is at C:\inetpub\wwwroot\website

The files I want to link to are in S:\someFolder

Can I make a link in the webapp that will direct to the file in someFolder?

Upvotes: 0

Views: 711

Answers (6)

Hugh Allen
Hugh Allen

Reputation: 6695

A solution which works at the OS level rather than the webserver level is to make a symbolic link.

Links to files are supported on Vista and links to folders ("junctions") are supported on Win2000 onwards.

Upvotes: 0

stefano m
stefano m

Reputation: 4244

i think there are only two ways 1) make a virtual path wich points to download directory 2) call a your aspx/ashx handler wich load file locally and send it to client.

Upvotes: 0

Matthew Cole
Matthew Cole

Reputation: 1339

Do you have another virtual directory/application pointing to s:\someFolder? If so, it's just a simple link.

Are you trying to stream files back? If so, take a look at Response.TransmitFile and Response.WriteFile.

Otherwise, maybe you could create a handler (.ashx) to grab a specified file and stream its contents back?

Upvotes: 0

Devin Ceartas
Devin Ceartas

Reputation: 4829

That depends on the configuration of your web server. Probably not. You don't want the web server to be able to access any file on the hard drive (ie your passwords file), so only those files configured to be accessible in the web server's configuration files are accessible and can be linked to. Usually these are all kept under one directory. You could, of course, copy someFolder and place it under your web directory, then it would be accesible, or if you are sure it is safe, change the configuraton of your web server to allow access to that folder.

Upvotes: -2

user17250
user17250

Reputation: 146

You would have to specifically map it to some URL through your web server. Otherwise, all your files would be accessible to anyone who guessed their URL and you don't want that...

Upvotes: 0

Rob Cooper
Rob Cooper

Reputation: 28867

If its on a different drive on the server, you will need to make a virtual directory in IIS. You would then link to "/virtdirect/somefolder/"

Upvotes: 8

Related Questions