BeetleDev.com
info
Saturday, September 26, 2020
Beetle Blog
Force file download with C#
By: douglas - C# - 10/3/2002 12:00:00 AM

Normally when you click on a link to a file the browser will try to read or open that file automatically. This code will force the browser to open the "Save As..." dialog box using a swf file as an example.

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
  Response.ContentType = "application/x-shockwave-flash";
  Response.AppendHeader("content-disposition","attachment; filename=button1.swf");
  Response.WriteFile((string)MapPath("button1.swf"));
  Response.End();
}
</script>

 


Last Modified: 4/26/2005 1:36:16 AM

Beetle Blog v0.2.2


Copyright © 1997 - 2020 BeetleDev.com. All rights reserved.