ASP.NET Download Files

Download any file type from a web form in ASP.NET. This example downloads zip files.

<%@ Page Language="C#" ContentType="application/x-zip-compressed" %>
<%
	Response.Clear();
	Response.AppendHeader("content-disposition", "attachment;filename=" + Request.QueryString["file"]);
	string file = Server.MapPath("/zipfiles/" + Request.QueryString["file"].Replace("../", ""));
	Response.WriteFile(file);
	Response.End();
%>