I am using following code to output html string into word document with .docx extension [not .doc]
private void ExportBodyAsDoc(string strBody) {
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "Application/msword";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=myfile.docx");
var repo = new System.IO.MemoryStream();
var stringBytes = System.Text.Encoding.UTF8.GetBytes(strBody);
repo.Write(stringBytes, 0, strBody.Length);
HttpContext.Current.Response.BinaryWrite(repo.ToArray());
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Close();
HttpContext.Current.Response.End();
}
It is only working with firefox while in other it is corrupting the document.