manually Send file to client

  • Thread starter Thread starter wackyphill
  • Start date Start date
W

wackyphill

Is there a way to code it so that you can transmit a file to a client
programatically so that you could send it a file that is not part of
your website?

Like if my site is in c:\inetpub\mySite

Is there a way I can use like FileStream and read in a file from c:\
and then somehow transmit it to the client. (Purpose being to force the
user to go thru the website to access files and stop someone from
directly putting the url of the file they want to download in the
address bar)

I'm not sure how to transmit the data to the client though. Any ideas?
Thanks very much.
 
You can use Response.WriteFile to write any file on the server out to the
client. So if the file is outside the virtual directory, WriteFile will
write it out just fine, but the user would have no way of specifying a URL
for it, since it will be outside the virtual directory.
 
Yeah, that works very well for downloading.

How about this though:?

You know how if you link to a .NET app in a web page and the client
clicks on the link using IE the program is downloaded and executed on
the client's machine?

Anyway of reproducing that same "link clicked" type behavior for a .NET
app (using Response.Writefile or something else) I have outside my
website so it will run automatically instead of the user having to hit
run on the save/as dialog?

Because w/ regular links the program simply runs when its link is
clicked. I'm not sure what the header's are that get sent when a link
is clicked like that.
 
You might want to use a Smart Client application if you want an app to run
when they click on the link.
The user is always going to be presented with a dialog box before any file
is downloaded to their computer though. This security precaution is well
warranted.
Would you want web sites automatically downloading strange files to your
computer without your permission? I think not.
 
I'm not sure what you mean by smart client.

And there is no confirmation when you click on a link to a .net
executable. It is downloaded cached and run w/o any user interaction at
all.

The only thing you may have to do is set the source as being trusted
depending on what the app needs to do.
 
Back
Top