I am developing an ASP.NET app which at one point sends a file to the user, using Response.TransmitFile.
It works fine on my dev machine, and when I deploy it to the test servers it still works on two of them; in one of the servers though (W2K3) it only works on Firefox, when I try it on IE7 I get an error like "Internet Explorer cannot open file sendfile.aspx on (server name)".
I've created a small inline aspx page to repro the problem, here it is:
<%@ Page Language="C#" %>
<html><head>
<script language="CS" runat="server">
void Page_Load(object sender, System.EventArgs e)
{
string filePath = @"C:\temp\export.zip";
Response.ClearHeaders();
Response.ContentType = "application/zip";
Response.Clear();
Response.AppendHeader("Content-disposition", "attachment; filename=export.zip");
Response.TransmitFile(filePath);
Response.End();
}
</script>
</head></html>
I've tried different things and I noticed that it works again if I comment out the Response.End
line (but AFAIK this line should be there, at least according to every sample code I find around the web)
Another issue I noticed which may or may not be related is that it will also fail if I remove the <html>, <head>
and its closing tags.
I've been scratching my head over this for a while now, does anyone have a clue how to get this to work?