Hi all,
I am experiencing a strange error in an aspx page. What I am trying to do is simply export some HTML into an MS Word doc. I am doing this through the following code:
StringWriter stringWrite = new StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
if (ctrl is WebControl)
{
Unit w = new Unit(100, UnitType.Percentage);
((WebControl) ctrl).Width = w;
}
ctrl.RenderControl(htmlWrite);
string strHTML = stringWrite.ToString();
string getPath = PagePath.Replace("Print.aspx", @"Images/ntlogo.jpg");
strHTML = strHTML.Replace("Images/ntlogo.jpg", getPath);
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AddHeader("Pragma", "public");
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + "Certificate.doc");
HttpContext.Current.Response.ContentType = "Application/msword";
HttpContext.Current.Response.Write(strHTML);
HttpContext.Current.Response.End();
When I run the application from a web server on my LAN or on my local machine, this brings up a save dialog and works perfectly as expected. However, when accessing this from IE from a site hosted elsewhere, nothing happens. Firefox works. If popups are unblocked it makes no difference. I dont want to have to change a browser setting to get this to work in IE. Howcome it does not work? What can I change to make the save dialog appear in IE when accessing the site from a remote location? Seriously confused, any help would be greatly appreciated.
Thank you