Tip: When Asp.net downloads a default file name that contains spaces, how to prevent FireFox from intercepting only the first part of the space as the file name

Source: Internet
Author: User
Previously I wrote a Post: Tip: Specifies the default file name in the dialog box when the browser downloads and saves dynamically generated data. However, if the specified file name contains spaces, fireFox uses the part before the space as the default file name.
The solution is simple: Enclose the file name with double quotation marks: Response. AppendHeader ("Content-Disposition", "attachment; filename = \" "+ fileName + "\"");
Response. ContentType = "application/octet-stream ";

However, the problem persists. in IE, if the file name contains two English names (period, character '. '), it will automatically add "[1]" before the first point, so your original file name is "aaa. bbb. whatever "becomes" aaa [1]. bbb. whatever ". who knows how to solve this problem?

--------
Update: According to Microsoft, the second problem cannot be solved.
I said, let's persuade users to discard IE!

--------
Update:
The second problem can be solved as follows: If (Request. Browser. Browser. Contains ("IE "))
{
String ext = fileName. Substring (fileName. LastIndexOf ('.'));
String name = fileName. Remove (fileName. Length-ext. Length );
Name = name. Replace (".", "% 2e ");
FileName = name + ext;
}
Response. AppendHeader ("Content-Disposition", "attachment; filename = \" "+ fileName + "\"");
Response. ContentType = "application/octet-stream ";

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.