Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSV file download ignored in ie8/9

I have some code in a button click event which gets a csv string from a hidden input and writes it to the response as a CSV file.

This work fine in Chrome, Firefox, ie7, ie9 in quirks mode. However it does not work in ie8 or ie9 default.

Looking at this in fiddler the csv is being written to the response but the another get request is being made immediately after and the page reloads. No file saving dialog appears.

    protected void btnCsvHidden_Click(object sender, EventArgs e)
    {
        var csv = csvString.Value;
        var filename = "Reporting";

        Response.Clear();
        Response.ClearHeaders();
        Response.AddHeader("Cache-Control", "no-store, no-cache");
        Response.AddHeader("content-disposition", "attachment; filename=\"" + filename + ".csv\"");
        Response.ContentType = "text/csv";
        Response.Write(csv);
        Response.End();
    }
like image 795
JBB Avatar asked Dec 19 '12 17:12

JBB


1 Answers

The problem was with my own IE, I ran a load of windows updates and now it works so I'm not sure what it was exactly.

like image 152
JBB Avatar answered Nov 18 '22 07:11

JBB