[RESOLVED] Response.WriteFile returns the aspx page!
Hi all,
My code generates an excel file and should be sending it to the user for download. Instead, the user is getting the .aspx page as an .xls file! o.O
Can someone shed some light on this? Many thanks in advance
Code:
Response.ContentType = "application/x-msexcel";
System.IO.FileInfo fileToDownload = new System.IO.FileInfo(filename.ToString());
System.String disHeader = "Attachment; Filename=\"" + fileToDownload.Name + "\"";
Response.AppendHeader("Content-Disposition", disHeader);
Response.Flush();
Response.WriteFile(fileToDownload.FullName);
Re: Response.WriteFile returns the aspx page!
I seem to have solved this :)
The problem: the Excel process was still running when I attempted to transmit the file. This triggered an exception which somehow lead to the aspx file being transmitted O.o
Hope this helps someone else in this situation