Send Document to Client's Web Browser for Download or Open with MS Word | C# ASP.NET | Save Word Document with UNC Path

Hi All

A client event - within my ASP.NET application - triggers the generation of a Word document on the server and this document will be saved in a specific folder on the file server.

Then I would like to send the Word Document to the client to enable the client to make last minute changes to the document. Two things which I would like to know more about:

1. If the application type of the response is Word, Word opens within the Browser. Some Toolbars are not displayed and the user get's confused to a certain degree. Is there a way to be able to present the Word Document to the user within a normal WinWord instance on the client?

2. Is there a way that the user can save the Word document within word directly on the file server (via UNC path)?

Any help is really apprechiated.

Thanks a lot

Tinu

Answering your first question:

If you have send document using:

doc.Save("Aspose.Words.Demos.doc", SaveFormat.FormatDocument, SaveType.OpenInBrowser, this.Response);

Then, initially you are given two options for document receive from server: open and save. There is also a checkbox saying 'Always ask before openning this type of file'.

If you haven't checked this checkbox already you can choose whether to save the file and open it with MS Word later, or open it immediately in the browser window.

Or you can send document to client using:

doc.Save("Aspose.Words.Demos.doc", SaveFormat.FormatDocument, SaveType.OpenInWord, this.Response);

Then the document should open in MS Word directly.

Answering the second question:

UNC names like \\server\share\filename should work ok when saving document from MS Word, provided that the path is valid and client has necessary permissions.

Thanks for your response!

miklovan wrote:

Or you can send document to client using:

doc.Save("Aspose.Words.Demos.doc", SaveFormat.FormatDocument, SaveType.OpenInWord,this.Response);

Then the document should open in MS Word directly.

If I'm using this command, will Word try to save the Word Document according to the UNC path or is the path pointing to the temporaray directory on the client?

Does Aspose.Words inject the UNC path?

Cheers

Tinu

No, this command does not save sended document on the client side, just opens it in MS Word.

OK, so this is appropriate within a WinForm Client.

Is there any support from Aspose.Words in relation to sending the Word Document to the client within a Web Application (ASP.NET/C#) and injecting the UNC path?

Thanks

Tinu

Please specify - what do you mean by injecting UNC path?

Sorry for not beeing clear. Our application is an ASP.NET/C# solution.

1. User requests a Word document to be produced on the server.

2. We produce that Word document with ASPOSE.Words and save it on the file server: \\FileServer1\CustXYZ\2006\2334.doc

3. We send the Word document to the client where it opens MS Word on the clients computer.

4. The client works on the document.

5. When he hits the save button, the Word document will be saved as \\FileServer1\CustXYZ\2006\2334.doc

Any ideas how to solve this requirement (point 3 & 5)?

Thanks

Tinu

Document itself does not store any information on the path it was loaded from or shoud be saved to - that is for sure.

Still, I presume that this can be achieved using Javascript code that executes on the client side, although not being javascript specialist it is relly hard for me to give any concrete recomendations on javascript coding.

But the logical sequence should be something like this:

  • save document to \\FileServer1\CustXYZ\2006\2334.doc on server side,
  • send client javascript with instruction to open file from \\FileServer1\CustXYZ\2006\2334.doc
  • this javascript will be executed on client side, opening file in MS Word (from UNC path not from response),
  • MS Word knows the path of the document that was loaded and when user hits Save it will store the changed document to the same path,
  • server application monitors files using .NET FileInfo class, it receives an event when the file is saved on a disk by client,
  • server application makes necessary actions that stem from the fact that the document was finalized by user.

Thanks for your feedback. I believe that should work.

Regards

Tinu

Did you ever get anywhere in achieving this functionality?

I’m trying to do something similar so the user does not have to pick the folder to save the document in. How did you get it to save it directly to the filesystem instead of opening in the browser or word?

Thanks,

Josh