xBrowser CSV Content Types

  • Thread starter Thread starter trullock
  • Start date Start date
T

trullock

Hi,

Ive got a button on a page which creates a CSV and writes it to the
response stream for the user to download...

private void btnCSV_Click(object sender, EventArgs e)
{
Response.ContentType = "text/plain";
Response.AddHeader("content-disposition", "attachment; filename=
\"List.csv\"");
Response.Write(CreateCSV());
Response.End();
}

This works fine in IE.

In FF however, if i chose "open with excel" it saves the file in the
temp folder as "List.csv.xls", so when excel tries to open it it
thinks its an xls and doesnt parse it correctly as a csv :( If i save
it then open it, it of course works fine.

Is this just a problem with FF/Excel, or is there something i can do
with the content-type/other headers to fix this?

Thanks

Andrew
 
If I had to take a guess, I would guess that it is one of two things:

1. Firefox is attempting to correct to known types (possible)
2. Firefox is calling a windows API call that corrects to known types
(probable)

Either way, the only way "around" the issue is to change to Excel (and
convert list to table) when you detect firefox and allow the user to save
off as CSV. There is probably another creative way around, but it is not
coming to mind at this point in time.

There were a lot of issues with the last NetScape/Microsoft fight in the
late nineties. As the web has become more complex, or rather "the browsers",
this second fight (Firefox, ultimately, comes from NetScape) is a bit
messier. It gets even more fun when you start dealing with "standards" and
how each side interprets them. :-)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*********************************************
Think outside the box!
*********************************************
 
Back
Top