views:

158

answers:

2

This a bit of strange one.... We have an internal web app that runs on server (A) and a document repository that runs on server (B).

I have simple link on a page and I want to enable the user to download a document(From IIS Server (A)). However this document does not exist on Server (A) until the user clicks the button(because there is 40+ documents to display cannot load them all when the page loads)

When the user clicks the link(at which point I would like then to be prompted to download) The document is copied to server (A) and then redirected to a page where the browser prompts them to download. I believe I have set up the content header correctly and it works in FireFox.

IE(7) just pops up a window and then the window disappears, If I turn down the security settings it works OK but that is not an option.

Any Ideas how to solve this. I cannot point directly to the document on Server(B)

ADDITION: Yes Server B is also a Web Server

A: 

Can you use ajax? For example, the user clicks the button sending a request to get the file from B to A and a spinner shows up on the page. Then when the copy is done, you disable the spinner and give the user a download link.

I was voted down and don't have comment privileges, so I figured I would elaborate here (perhaps this is just a terrible solution and I cannot see it):

  1. User requests file by clicking link
  2. Request is sent to server A and it disables the link via ajax
  3. Server A copies the file to a temporary directory from server B
  4. Server A sends back a link to the file in the temporary folder

This would work if the document server was not a webserver (SMB, AFS, NFS, etc).

jeremy
"Any Ideas how to solve this. I cannot point directly to the document on Server(B)", it can't be done because of this last sentence.
Nick Berardi
This is really bad because it relies on actions that are not necessary, such as disabling the link. You could just as easily just click on the link download the file and then respond with the file, with out all the AJAX. The browser is going to be locked while waiting for the response anyways.
Nick Berardi
+5  A: 

If the world can see server A and server A can see server B. I would recommend setting up a reverse proxy.

http://www.codeplex.com/urlrewriter

Basically what this does is allows the world to download from server B but only through the reverse proxy. You can create a reverse proxy interface with this library above with the following rule.

RewriteRule ^/download/(.*) http://server-b/download/$1 [NC,P]

So in the case of

http://server-a/download/xyz.pdf

it would actually request it from

http://server-b/download/xyz.pdf

but it would be delivered as if it was coming from server-a, this technically happens by the reverse proxy creating a web connection, from server-a, to server-b and copying the HTTP response to the response of server-a.

Let me know if you need any help.

Nick Berardi
I was writing the same solution when yours appeared :-). I just want to point out a caveat, server B needs a web server for this to work.
Vinko Vrsalovic
Very true, I guess I made that assumption, however that is usually pretty easy to come from. If it is not a server, should just use a network drive to deliver the files from A.
Nick Berardi