xBrowser CSV Content Types

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
 
C

Cowboy \(Gregory A. Beamer\)

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!
*********************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top