We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problems with resulting document from a web based: .Save(this.response- filename.....)


We have been using Aspose.Words for .Net for several years now. And recently upgraded from version 5 to the latest version. (Yeah, I was a bit of a slug.)All has gone swimmingly, but we are now having one particular issue that is causing problems.

After dynamically creating a word document from a number of chosen documents, I am using the following line to send the word document to the user's browser:

batchDocument.Save(this.Response, outputFileName, ContentDisposition.Inline, null);

This always worked before, and the resulting document had the unique outputFileName that I created in the code. But now, all of the documents open with the name of the .aspx file that generated the document. In this case it's AttachmentBatchPrint.aspx. This is wreaking havoc with several of our clients. I would really like to get things back to having the resulting document show with my created filename not the .aspx name.

Here is the flow:

  • User selects one or more documents to batch.
  • This information is passed to my AttachmetnBatchPrint.aspx page. This page pulls in the chosen documents and appends to the first document.
  • A filename (string) is chosen from certain identifying id values, and a random number, and then is given a ".doc" extension.
  • This document then uses the Save method as mentioned above.
  • The user is prompted to open the file. Interesting to note that the document's file name is shown to be the correct .doc file name.
  • Clicking open, the user is shown the correct document, but the "temporary" filename IE uses is AttachmentsBatchPrint.aspx instead of the correct filename.
  • This all worked superbly until I upgraded Aspose.Words.I will also say that when I upgraded Aspose, I had to change the Save method call here to the new one mentioned above:

batchDocument.Save(outputFileName, SaveFormat.Doc, SaveType.OpenInWord, this.Response);

Now... this is a tiny piece of a rather gargantuan and complex code base that I have constructed. So I don't think I can post a "simple" example. I have no other code that preps any web response, nor any caching, nor anything like that.

Thanks all.


Thanks for your request. I suppose this occurs because you did not specify SaveFormat explicitly. Please try using the following code:

doc.Save(this.Response, outputFileName, ContentDisposition.Inline, SaveOptions.CreateSaveOptions(SaveFormat.Doc));

Hope this helps.

Best regards,

That did not help. But, I have solved this problem. I changed: ContentDisposition.Inline to ContentDisposition.Attachment and now it works.ContentDisposition.Inline to ContentDisposition.Attachment and now it works.



It is perfect, that you already resolved the problem. Please let us know in case of any issues. We will be glad to help you.

Best regards,