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

Free Support Forum - aspose.com

Aspose.Words (17.1.0.0). Exception when saving to stream (works fine in 16.11.0.0)

Hi, we have a new problem after updating from Aspose version 16.11.0.0 to version 17.1.0.0.

The following code line saving a document to a Stream works fine in Aspose Words version 16.11.0.0, but fails in version 17.1.0.0

document.Save(Response.OutputStream, Aspose.Words.SaveFormat.Docx);

This is the error message in version 17.1.0.0:

[NotSupportedException: Specified method is not supported.]
System.Web.HttpResponseStream.get_Position() +33
. (
) +49
Aspose.Words.Document. (
, SaveOptions ) +175
Aspose.Words.Document. (Stream , String , SaveOptions ) +443
Aspose.Words.Document.Save(Stream stream, SaveOptions saveOptions) +39
Aspose.Words.Document.Save(Stream stream, SaveFormat saveFormat) +28

This is the complete code snippet:

Aspose.Words.License license = new Aspose.Words.License();
Aspose.Words.Document doc1 = new Aspose.Words.Document(path1);
Aspose.Words.Document doc2 = new Aspose.Words.Document(path2);
doc2.Compare(doc1, page.core.userID, System.DateTime.Now);
Response.BufferOutput = true;
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "application/octet-stream";
string fileName = filename1.Replace(".","*") + " - " + filename2.Replace(".","*") + ".docx";
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
doc2.Save(Response.OutputStream, Aspose.Words.SaveFormat.Docx);

Help is greatly appreciated!

Thanks and kind regards

Sven Andersen

Hi Sven,

Thanks for your inquiry. Please try using Document.Save method (HttpResponse, String, ContentDisposition, SaveOptions) method. Hope this helps you.

If you still face problem, please attach your input Word documents here for testing? We will investigate the issue on our side and provide you more information.

Thanks Tahir, the problem is completely independent of Word files used, any two Word files will reproduce the problem. I can reproduce the problem in latest Aspose Words version 17.2.0. Aspose.Words version 16 Works fine and seems more stable, so we have to stick to this until we find solution.

I cannot find instance of Save method with 4 parameters as You suggest. 2 parameters are the max. And no one with HttpResponse as parameter type. These are the instances I find:

public SaveOutputParameters Save(string fileName);
public SaveOutputParameters Save(string fileName, SaveOptions saveOptions);
public SaveOutputParameters Save(Stream stream, SaveFormat saveFormat);
public SaveOutputParameters Save(string fileName, SaveFormat saveFormat);
public SaveOutputParameters Save(Stream stream, SaveOptions saveOptions);

I tried using SaveOptions instead of SaveFormat like this:

Aspose.Words.Saving.SaveOptions saveOptions = Aspose.Words.Saving.SaveOptions.CreateSaveOptions(Aspose.Words.SaveFormat.Docx);
doc2.Save(Response.OutputStream, saveOptions);

Then I get the following error:

Specified method is not supported.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: Specified method is not supported.
Source Error:
Line 153: //doc2.Save(Response.OutputStream, spose.Words.SaveFormat.Docx);
Line 154: Aspose.Words.Saving.SaveOptions saveOptions = Aspose.Words.Saving.SaveOptions.CreateSaveOptions(Aspose.Words.SaveFormat.Docx);
Line 155: doc2.Save(Response.OutputStream, saveOptions);
Line 156: return;
Line 157: }

Thanks, and kind regards

Sven Andersen

Hi Sven,

Thanks for your inquiry. Please check overloaded methods of Document.Save method. We suggest you please use net2.0 assembly of Aspose.Words.

The DocumentSave method (HttpResponse, String, ContentDisposition, SaveOptions) is not available when using the .NET Client Profile DLL. This DLL is located in the net3.5_ClientProfile folder. The .NET Client Profile excludes assemblies such as System.Web therefore HttpResponse is not available. This is entirely by design.

This can manifest itself as an error:

“No overload for method ‘Save’ takes ‘4’ parameters.”