Asp tutorial. net url transfer 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 Chinese characters, encode the Chinese parameters to be passed and decode them upon receiving them.
> 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. If a Chinese parameter is transferred from the. html file to the. aspx file (that is, url conversion is not performed using the redirect () method from the background ). Similarly, the passed Chinese parameters must be encoded and decoded upon receiving.
> Transfer
<Script language = "webpage effect">
Function gourl ()
{
Var name = "Chinese parameter ";
Location. href = "B. aspx? Name = "+ escape (name );
}
</Script>
<Body onclick = "gourl ()">
> Receive
String name = request. querystring ["name"];
Response. write (server. urldecode (name ));
Instance method
Project
String url = "http: //" + arr [2] + ": 111/loginif. aspx? Uid = "+ server. urlencode (arr [0]) +" & pwd = "+ arr [1]; // transcode a Chinese account
Clientscript. registerclientscriptblock (this. gettype (), "this", "<script> window. open ('"+ url +"') </script> "); in this way, the parameter uid is passed to Chinese
Receive in Project B
Userloginif (server. urlencode (request ["uid"]. tostring (), request ["pwd"]. tostring (); // transcoding required for Chinese Characters
Encoding
Sender 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 encoding and decode is decoding.
If not,
Use the post method, or use the requestheader, or
Use webservice for proxy forwarding.