Controlling file download using header content

October 15, 2008 | In Development |

Here’s a code snippet I was searching for the other day.  It’s a straight forward header modification for a web page which I used to download a CSV file directly into the file type handler setup on the local computer for Microsoft Excel files.  The user is prompted with the usual save/open dialog.

this.Response.Clear();
this.Response.ClearHeaders();
this.Response.ContentType = "application/vnd.ms-excel";
this.Response.AddHeader("Content-Disposition", "attachment; filename=<insert file name here>; size=<insert file size in bytes here>“);
this.Response.Write(<file>);
this.Response.End();

No Comments yet

TrackBack URI

Sorry, the comment form is closed at this time.

Login | XFN| WP
Powered by WordPress with cmb-web Theme design by Christian Bridge-Harrington.
Blog feed. Valid XHTML and CSS. ^Top^