There are generally three solutions:
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 = "JavaScript">
Function gourl ()
{
VaR name = "Chinese parameter ";
Location. href = "B. aspx? Name = "+ escape (name );
}
<Body onclick = "gourl ()">
> Receive
String name = request. querystring ["name"];
Response. Write (server. urldecode (name ));
Summary:
In general. Set the Web. config file. However, if you use JavaScript to call the WebService method (passing Chinese parameters to WebService ). The Web. config file is invalid.
Or use
Response. Redirect ("test1.aspx? 111 = "+ system. Web. httputility. urlencode (" People's Republic of China "));
// It is recommended that you obtain Chinese parameters from other pages without garbled characters.
String message = "http: // localhost/test/test1.aspx? 111 = "+ system. Web. httputility. urlencode (" People's Republic of China ");
HTTP:
// You need to obtain the address of the return value of a page"
// Send the request
Httpwebrequest myhttpwebrequest = (httpwebrequest) webrequest. Create (Message );
// Accept the request
Httpwebresponse myhttpwebresponse = (httpwebresponse) myhttpwebrequest. getresponse ();
Stream receivestream = myhttpwebresponse. getresponsestream ();
Streamreader readstream = new streamreader (receivestream, system. Text. encoding. getencoding ("gb2312 "));
// This is the returned result of the return value of the page to be retrieved.
Returnvalue = readstream. readtoend ();