Garbled text in the address bar after the asp.net url is passed (more than two Chinese characters in Chinese)

Source: Internet
Author: User

The encoded url is correct. If it can be uploaded to another page, an error will occur and garbled characters will appear in the address bar.
1. Set the web. config file
Copy codeThe Code is as follows:
<System. web>
<Globalization requestEncoding = "gb2312" responseEncoding = "gb2312" culture = "zh-CN" fileEncoding = "gb2312"/>
</System. web>

2.asp.net
Transfer
String Name = "Chinese parameter ";
Response. Redirect ("B. aspx? Name = "+ Server. UrlEncode (Name ));
Receive
String Name = Request. QueryString ["Name"];
Response. Write (Server. UrlDecode (Name ));
3. Upload values to the asp.net page using javascript
Copy codeThe Code is as follows:
<Script language = "javascript">
Function escode ()
{
Location. href = "B. aspx? Name = "+ escape (Name );
}
</Script>

On the asp.net page, you can use Request. QueryString ("Name"). toString () to obtain the correct Chinese characters.

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.