ASP tutorial. Net URL Pass Chinese garbled solution
1. Set the Web.config file.
<system.web>
......
<globalization requestencoding= "gb2312" responseencoding= "gb2312" culture= "ZH-CN" fileencoding= "gb2312"/>
......
</system.web>
2. Before passing the Chinese language, the Chinese parameters to be passed are encoded and decoded at the time of receiving.
>> to deliver
String name = "Chinese parameters";
Response.Redirect ("B.aspx?name=" +server.urlencode (name));
>> to receive
String name = request.querystring["Name"];
Response.Write (Server.urldecode (name));
3. If you are passing a Chinese parameter to an. aspx file from an. html file (that is, not using the redirect () method for URL conversion from the background). To encode the passed Chinese parameters and decode them when they are received.
>> to deliver
<script language= "Web Effects" >
function Gourl ()
{
var name = "Chinese parameter";
Location.href = "B.aspx?name=" +escape (name);
}
</script>
<body onclick= "Gourl ()" >
>> to receive
String name = request.querystring["Name"];
Response.Write (Server.urldecode (name));
Instance method
In Project A
String url = "http://" + arr[2] + ": 111/loginif.aspx?uid=" + Server.URLEncode (arr[0]) + "&pwd=" + arr[1]; Chinese Account Transfer Code
Clientscript.registerclientscriptblock (This.gettype (), "This", "<script>window.open" (' + URL + ') </script > "); This pass parameter UID is in Chinese
B in Project receive
Userloginif (Server.URLEncode (request["UID"].tostring ()), request["pwd"].tostring ()); Chinese must turn code
Specify encoding
Sending party Server.URLEncode ("Chinese", Encoding.GetEncoding ("gb2312"));
Receiver Server.urldecode (request["key"], encoding.getencoding ("gb2312"));
Userloginif (Server.urldecode (request["UID"].tostring ()), request["pwd"].tostring ());
Encode is encoded, decode is decoding.
If not yet,
Use the Post method, or use Requestheader, or
Consider using WebService to do proxy forwarding.