asp.net to prevent the download of Chinese file names appear garbled

Source: Internet
Author: User
Tags urlencode

ASP tutorial. NET to prevent the download of Chinese file names appear garbled
Prevent the download file name in Chinese name and appear garbled available UrlEncode
*/
//

Response.AddHeader ("Content-disposition", "Attachment;filename=" +server.urlencode ("www.111cn.net Chinese. rar"));
/*
In the ASP.net tutorial Server.URLEncode used the encoding method is UTF8
So when we pass the characters, we find that the results are different from the ASP.
The solution is Httputility.urlencode, and you can specify how he encodes it.
such as Httputility.urlencode ("kanji", encoding.default) gets the encoding of the system's current ANSI code page


About UrlEncode
The UrlEncode method applies the URL encoding rule, including the escape character, to the specified string.

Grammar
Server.URLEncode (String)

Parameters
String
Specifies the string to encode.
Example
Script

<%response.write (Server.URLEncode ("Http://www.111cn.net"))%>

Output

Http%3a%2f%2fwww%2111cn%2enet

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.