I'm having problems when trying to use the Open option in Internet Explorer when serving an excel document from an ASP.NET web app.
Response.AddHeader("content-disposition", "attachment;filename=" + filename.Replace(",", "") + ".xls");
Response.Charset = String.Empty;
Response.ContentType = "application/vnd.xls";
using (StringWriter sw = new StringWriter())
using(HtmlTextWriter hw = new HtmlTextWriter(sw))
{
gridView.RenderControl(hw);
Response.Write(sw.ToString());
}
Response.End();
I didn't write the code but what I have noticed is that if the filename length is <= 177 then it works. Anything over >= 118 I receive a file could not be found error. I've checked the the 118th character is a 0 so doesn't appear to be anything to do with this.
Any ideas what might be causing this as it seems to work fine in Chrome and Firefox.