Kudos Karyani!
For .xls files, that's eliminating this particular message, on my application that involves a DataGrid and SQL Server. Incidentally, that application had been failing to download Word 2007 files; this edit fixed it.
On the other hand, for the application I tried this with earlier, I continue to get the message.
Differences between the two apps follow.
App where the message persists (App A):
2.0 .Net C# SqlServer2005 (file not stored in SQL though) GridView
Does not store the file content in a database rather sends it directly to the browser as a Response
App where the Excel 2007 message stopped appearing and also the Word 2007 download was enabled by this edit (App B):
1.1 .Net VB SqlServer 8.0 DataGrid
App first redirects to a blank aspx where the Response is composed.
App A (rendering GridView grvRequestors to a Response)
string attachment = "attachment; filename=Requestors.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType =
"application/vnd.ms-excel";StringWriter sw = new StringWriter();HtmlTextWriter htw = new HtmlTextWriter(sw);
grvRequestors.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
App B (download a file whose content is stored as binary in SQL)
When users clicks to download:
Response.Redirect("./downloadFile.aspx")
in downloadFile.aspx
Response.AddHeader("Content-disposition", "attachment;filename=" & dsAttachments.Tables(0).Rows(0)("FileName"))
Response.ContentType = dsAttachments.Tables(0).Rows(0)("FileType")
Response.BinaryWrite(dsAttachments.Tables(0).Rows(0)("Attachment")) 'content
Response.Flush()