The configuration in Web. comfig is the same:
<Globalization requestencoding = "gb2312" responseencoding = "gb2312"/>
The header part of the page also has
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
Strange,
I had to use the stupid method:
Write parameters:
String strurl = preurl + "? WORD = {0} & sort = {1} & check = {2 }";
Strurl = string. format (strurl, httputility.urlencode(this.txt searchtxt. text. trim (), system. text. encoding. getencoding ("gb2312"), this. radiosortdesc. selectedindex. tostring (), checkstate. tostring ());
Page. response. Redirect (strurl );
// Note that the encoding method is gb2312.
Read parameters:
Try
{If (page. Request. querystring ["word"]! = NULL)
{_ Word = convert. tostring (httputility. urldecode (page. Request. querystring ["word"], system. Text. encoding. getencoding ("gb2312 ")));}
}
Catch {_ word = string. Empty ;}
/// Note that the encoding method is gb2312, which corresponds to the preceding
Later, I read Article To find a better solution:
Use JavaScript!
Write a method to the base class page
Public void pagelocation (string chineseurl)
{
If (chineseurl = NULL | chineseurl. Trim (). Length = 0)
{Return; // It may not be a legal URL, Tony 2007/11/15
}
Page. clientscript. registerstartupscript (this. getType (), "agronetpagelocationto", "<SCRIPT type = 'text/JavaScript 'Language = 'javascript'> window. location. href = '"+ chineseurl +"'; </SCRIPT> ");
}
Then, call
String strurl = preurl + "? WORD = {0} & sort = {1} & check = {2 }";
Strurl = string. Format (strurl, this.txt searchtxt. Text. Trim (), this. radiosortdesc. selectedindex. tostring (), checkstate. tostring ());
Pagelocation (strurl );
Note that the latter method uses javasrcept. in actual application, Chinese parameters need to be kept during paging. It is best to use the window. Location. href method!
finally, if. net background Code for dialog, you can do this:
receive:
string name = request. querystring ["name"];
response. write (httputility. urldecode (name);
the key point is:
encode the passed Chinese parameters and decode them when receiving them.
when you are young, you need to do things less nonsense and more.