I'm trying to generate a word document using StringBuilder, as follows
[WebMethod]
public static void ExportToWord(string HTMLContent)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentType = "application/msword";
string strFileName = "GenerateDocument" + ".doc";
HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName);
System.Text.StringBuilder strHTMLContent = new System.Text.StringBuilder();
strHTMLContent.Append(HTMLContent);
HttpContext.Current.Response.Write(strHTMLContent);
HttpContext.Current.Response.End();
HttpContext.Current.Response.Flush();
}
The problem is when i see the downloaded doc, it has the remaining page content added with the above <div> content