Click here to Skip to main content
15,886,617 members
Articles / Web Development / ASP.NET
Tip/Trick

Download File (Firefox Issue)

Rate me:
Please Sign up or sign in to vote.
4.80/5 (2 votes)
18 Mar 2014CPOL 11.8K   5   2
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...

C#
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...

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

This will download file with full name.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionThanks Pin
Abdul Khaliq6-Jul-17 0:48
Abdul Khaliq6-Jul-17 0:48 
AnswerRe: Thanks Pin
Member 1365572020-Apr-19 2:15
Member 1365572020-Apr-19 2:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.