While downloading .CSV it saves as an excel file.

  • Thread starter Thread starter ksskumar2000
  • Start date Start date
K

ksskumar2000

Hi Friends,

What I want:
If the user click a hyperlink, I have to download a .CSV file into the
users machine.

What I tried:
<asp:HyperLink id=HyperLink1 runat="server"
NavigateUrl="Sample.csv">download file.</asp:HyperLink>

The Problem:
While clicking the link the file downloading as an Excel file not as a
..CSV
Even in the "File Download: Do you want to open or save this file?"
dialog window shows like,
Name: Sample.xls
Type: Microsoft Excel Worksheet

My Question:
What I have to do to download the file as it is (.CSV)?

thanks in advance,
Kumar.
 
Hi,

Change the contenttype property of Response to "text/csv"
This will make the text written to browser in CSV format. However, this
will not throw the "Save As" dialog to the user

The browser is forcing you to save the csv using excel. Because the csv
extension is linked with Excel

Kalpesh
 
Back
Top