C # Or js url-based parameter-based Chinese garbled solution. The encoding format is set in web. config.

Source: Internet
Author: User

C #: When we use url to pass the parameter, such as index. aspx? Id = me. When the parameter value is a Chinese character, garbled characters are often encountered. Here are some solutions: 1. configuration File web. in the section "config", add the encoding method of the entire website. The Code is as follows: [html] <! -- Start from GB2312 encoded as Chinese --> <globalization requestEncoding = "gb2312" responseEncoding = "gb2312"/> <! -- End with GB2312 encoded as Chinese --> the parameter is transmitted in gb2312 Chinese encoding mode. The general default is the utf-8.2. In parameter passing is first encoded in transmission, accept first encoding, in receiving. String mm = Server. URLEncode (you); Response. Redirect (index. aspx? Mm = + mm), and then decode on the receiving page: string mm = Server. URLDecode (Requext. querystring (mm); js: Passing parameter: Use encodeURI ("url parameter") to encode the received parameter: Use decodeURI ("received value") to decode the received parameter.

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.