I am having a huge problem in all browsers.
I have a site where clients can download a csv file that contains detail they need.
The problem I am having is that the csv file either downloads with no extension or as a htm file.
In the code I am specifying the file name with .csv, the file on the server is also a .csv.
The code is as follows
context.Response.Buffer = true;
context.Response.Clear();
context.Response.ClearHeaders();
context.Response.ContentType = "text/csv";
context.Response.AppendHeader("Content-Disposition", @"attachment,
filename=" + ((string)Path.GetFileName(downloadFilePath)));
context.Response.WriteFile(downloadFilePath);
context.Response.Flush();
context.Response.Close();
I have tried context.Response.ContentType = "text/html"; and context.Response.ContentType = "application/octet-stream";.
It is running on IIS6.
Does anybody know what could be causing this?
Ok I have worked out why files are not downloading as CSV.
its because the file name has spaces in it, so I need to enclose the filename so that it doesnt cut off at the space.
Thank you for all your help