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. urlencodeOrHttputility. urlencodeunicode(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 );
}
</SCRIPT>
<Body onclick = "gourl ()">
> Receive
String name = request. querystring ["name"];
Response. Write (server. urldecode (name ));
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.
4. the HTML file transmits Chinese parameters to the ASPX page
> Transfer
<Script language = "JavaScript">
Function gourl ()
{
VaR name = "Chinese parameter ";
Location. href
= Onlinesend. aspx? Name = "+ encodeuri (name) +" & SID ="+ Math. Random (). tostring ();
// When requesting a page and passing parameters, add a transfer parameter (the value is a random number) to save the IE
// The browser does not consider the same page requested. Otherwise, the IE browser considers the page as the unified page of the request and opens the page from the cache.
// Surface, causing incorrect passing of parameters SID = "+ math. Random (). tostring ();
}
</SCRIPT>
<Body onclick = "gourl ()">
> Receive
String name = request. querystring ["name"]. tostring ();
Original post address: http://greatverve.cnblogs.com/archive/2011/06/25/url-character.html