Chinese garbled is the Web site development will often encounter problems, today we talk about the URL address of Chinese character parameter transfer garbled solution, there is a need for friends to refer to.
In CS file, use UrlEncode when you pass the parameter:
Response.Redirect ("b.asp tutorial x? Name= "+server.urlencode (Name));
Use UrlDecode when you connect to the parameter:
Response.Write (Server.urldecode (request.querystring["Name"]));
When the script passes the argument, use escape:
Location.href = "B.aspx?" Name= "+escape (Name);
The UrlDecode is still used when receiving the reference:
Response.Write (Server.urldecode (request.querystring["Name"]));
Summarize the three-point method
There are generally 3 ways to solve the problem:
1. Setting up the Web. config file
<system.web>
......
<globalization requestencoding= "gb2312" responseencoding= "gb2312" culture= "ZH-CN" fileencoding= "gb2312"/>
......
</system.web (www.111cn.net) >
2. Before passing the Chinese, the Chinese parameter to be passed is encoded, and then decoded when it is received.
>> for delivery
String Name = "Chinese parameter";
Response.Redirect ("B.aspx? Name= "+server.urlencode (Name));
>> to receive
String name = request.querystring["Name"];
Response.Write (Server.urldecode (Name));
3. If it is from. HTML file to. Aspx file to pass the Chinese parameter (that is, no Url translation from the background using the Redirect () method). It is necessary to encode the passed Chinese parameters and decode them when they are received.
>> for delivery
<script language= "JavaScript" >
function Gourl ()
{
var Name = "Chinese parameter";
Location.href = "B.aspx?" Name= "+escape (Name);
}
<body onclick= "Gourl ()" >
>> to receive
String name = request.querystring["Name"];
Response.Write (Server.urldecode (Name))
From:http://www.111cn.net/net/160/38841.htm
Solution of Chinese character parameter transfer garbled in ASP-address