0

I'm trying to transfer a file (word document) from my server to the client

I'm using this :

Response.TransmitFile(path);
Response.End();

In IE when I click open of the download popup, everything is ok and word open with my document.

The problem is when I click the save button in word, it pop me a security/connection popup. I have to give a username/password for mysite.com

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
GregM
  • 2,634
  • 3
  • 22
  • 37

1 Answers1

2

That is normal behaviour since Word handles files opened via browser differently - it tries to verify whether they are "WebDAV-accessible" and uses some MS-specific extensions in doing so... that in turn doesn't use your current browser session but tries/needs to establish a new which in turn leads to Word askting you for credentials.

IF you want to just download it locally you could by using a content-disposition header - this way Word sees it as a local file and tries to save it locally upon "Word save button press".

IF you really want it to be saved back to your site it gets a bit tricky... although as you are running on IIS you might be able to implement something in combination with the IIS-built-in WebDAV functionality...

EDIT - as per comments:

For how to use content-disposition http header see for example http://www.jtricks.com/bits/content_disposition.html

Yahia
  • 69,653
  • 9
  • 115
  • 144
  • No I want to save it locally, i'll look for the content disposition thanks – GregM Nov 12 '11 at 07:30
  • 1
    @GregM I added a link describing how to use the `content-disposition` header... HTH – Yahia Nov 12 '11 at 08:09
  • Since you help me so much with my problem, maybe you could help me with this : Now when I open the word it saves it in the local/temp folder, is there a way to change this, thanks ! – GregM Nov 14 '11 at 21:34
  • @GregM sorry, but this is nothing you can change from HTML/JS - it is how the browser itself implements a "open" for a download... you have to choose "save" in the browser dialog and then choose the location and then open it from there... only other option to change that would be to implement an ActiveX or similar – Yahia Nov 14 '11 at 21:39