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();
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();
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: https://reference.aspose.com/words/net/aspose.words/document/save/
Also using Aspose.Words .net 2.0 DLL with .NET 4.0 framework is perfectly fine, there will be no limitations
Thanks,
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.