65.9K
CodeProject is changing. Read more.
Home

Download File (Firefox Issue)

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.80/5 (2 votes)

Mar 18, 2014

CPOL
viewsIcon

11950

Issue in downloading file from asp.net

Description

When we download files from some Asp.net Page using the Response Header. If the file name contains any space then In Firefox it gets only the first word from file name and make it available to download, so after downloading the file due to lack of File Extension, a user faces problem in opening of the file. Also file would be in improper name.

Cause of Problem

Normally we use following line of code in our application...

Response.AddHeader("Content-Disposition", "attachment; filename=" + filename); 

This will skipped the following words from the file name

ex. If file name is : ABC MNO XYZ.xls then browser will download file with name ABC without extension.

Resolution

We can use following line of code which works properly in any browser...

Response.AddHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");  

This will download file with full name.