Warning after building document

Hi,

The following code gives me a warning ("The file doca[1] cannot be opened because there are problems with the contents.") If I click OK it eventually displays the word document.

However, could you please let me know why I am getting this warning?

public void btnClick(object sender, EventArgs e)

{

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.Write("ahbt");

doc.Save(HttpContext.Current.Response, "doca.docx", ContentDisposition.Inline, SaveOptions.CreateSaveOptions(SaveFormat.Docx));

}

Hi Vishal,

Thanks for your inquiry.

Perhaps there is junk data in the repsonse after the document that is causing this issue. Please try calling Response.End() straight after saving the document to the response.

If this does not help, could you please attach your output document here for testing?

Thanks,

Hey aske012 thanks for your reply.

Adding Response.End() worked.