I'm writing because I'm stuck on a problem, I have code that currently writes the output of an aspx page to a word document. This code works perfectly fine. However I need to actually save that file to the server. Here is the code that is working:
HttpContext.Current.Response.ContentType = "application/msword";
HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=IR-" + lblReportNumber.Text + ".doc");
HttpContext.Current.Response.Write(this.Page.ToString());
Here is what I have tried to do to get the desired results
string fileName = Path.Combine(Server.MapPath("~/"), "IR-" + lblReportNumber.Text + ".doc");
string page = this.Page.ToString();
The problem is, the .doc file that's written to the server only contains the page name for text and not the full contexts of the html.
So if I open the word document from my second set of code all I see is "clientpage.aspx" however the first block of code opens the fully formatted word doc.
Does anyone have any ideas?