Custom ASP.NET file download from a page
Custom ASP.NET file download from a page
We must have had 20 posts regarding variations on this theme.
This code (which
works for me) should be self-explanatory:
<%@
Page language="C#" debug="true" %>
<script language="C#"
runat="server">
private void Page_Load(object sender, System.EventArgs
e) {
Response.ContentType="application/zip";
Response.AppendHeader("Content-Disposition","attachment;
filename=myzipfile.zip");
Response.WriteFile(@"c:\inetpub\wwwroot\myzipfile.zip");
Response.Flush();
}
</script>
N.B. Reader
Shaun College added the following to chop off the extra junk that may be sent
by the ASP.NET runtime along with your file:
Response.AddHeader
("Content-Length", FileSize.ToString());
Submission Date: 10/30/2002 12:05:30 PM
Submitted By: Peter
Bromberg
My Home Page: http://www.eggheadcafe.com
By Peter Bromberg Popularity (176 Views)