-
January 20th, 2011, 05:00 AM
#1
[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);
It's not a bug, it's a feature!
-
January 21st, 2011, 03:21 AM
#2
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
Last edited by foamy; January 21st, 2011 at 07:47 AM.
It's not a bug, it's a feature!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|