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

Free Support Forum - aspose.com

Aspose.Words demo

I’m getting a compile-time error on a line of code and I don’t know why or how to fix it. The line in red is causing me the problem:


var resp = System.Web.HttpContext.Current.Response;
var doc = new Document(Server.MapPath("~/Reports/Report1.dotx"));
var mmDataSource = new PeopleDataSource(model);
doc.MailMerge.ExecuteWithRegions(mmDataSource);
doc.Save(resp, “Aspose.Words.Demo.doc”, ContentDisposition.Inline,
SaveOptions.CreateSaveOptions(SaveFormat.Doc));
resp.End();

The error is "Cannot resolve method."

The version is 10.8.0.0

Never mind…I was using the .net 3.5 client profile assembly. I switched to the .net 2.0 and the problem went away.

Hi Charles,


Thank you for your additional details. It is great to hear that you manage to resolve. You are always welcome and please feel free to ask if you have any query in future.


You can also use this code snippet with .NET 3.5


Document doc = new Document(fileName);

MemoryStream stream = new MemoryStream();

doc.Save(stream, SaveFormat.Doc);

Response.Clear();

//Specify the document type.

Response.ContentType = "application/doc";

//Other options:

//Response.ContentType = "text/plain"

//Response.ContentType = "text/html"

//Specify how the document is sent to the browser.

Response.AddHeader("content-disposition", "attachment; filename=MyDocument.doc");

//Another option could be:

//Response.AddHeader("content-disposition", "inline; filename=out.doc");

//Get data bytes from the stream and send it to the response.

byte[] bytes = stream.GetBuffer();

Response.BinaryWrite(bytes);

Response.End();


Hope this will help.


Thanks! Should we use the .net 2.0 assembly in a .net 4.0 web site? What are the drawbacks, if any?

Hi Charles,


Thanks for your inquiry. That's alright, i think there are no drawbacks.


Hi Charles,


Thanks for your inquiry. The .NET client profile excludes the System.Web assembly and therefore the HttpResponse is not available. This means that particular save overlod is not avalible. This is entirely by design. If you need to use Aspose.Words in ASP.NET application, I would recommend you use .NET 2.0 Client Profile and the following overload of Save method:<o:p></o:p>

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.document.save_overload_6.html


Also using Aspose.Words .net 2.0 DLL with .NET 4.0 framework is perfectly fine, there will be no limitations


Thanks,