This article summarizes the analysis. NET gets the method of solving the garbled problem of the URL Chinese parameter value. Share to everyone for your reference, specific as follows:
Workaround:
1. Set up 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.
String Name = "Chinese parameters";
Response.Redirect ("B.aspx?") Name= "+server.urlencode (Name));
String Name = request.querystring["name"];
Response.Write (Server.urldecode (Name));
3.JS Pass Chinese parameter:
function Gourl () {
var Name = ' Chinese parameter ';
Location.href = "B.aspx?" Name= "+escape (Name);
}
String Name = request.querystring["name"];
Response.Write (Server.urldecode (Name));
Summarize:
Generally speaking. You can set the Web.config file. But if you use JavaScript to invoke the WebService method (pass the Chinese parameter to the WebService). Setting the Web.config file appears to be invalid.
or by:
Response.Redirect ("test1.aspx?111=" +system.web.httputility.urlencode ("Chinese Republic of China"));
Recommended to use the last if it is from other pages to get Chinese parameters are not garbled, it is more simple
string message = "http://localhost/Test/test1.aspx?111=" + System.Web.HttpUtility.UrlEncode ("Chinese Republic of China");
http
You want to get the address of the return value of a page "
//Send request
HttpWebRequest myhttpwebrequest = (HttpWebRequest) webrequest.create (message);
Accept Request
HttpWebResponse Myhttpwebresponse = (HttpWebResponse) myhttpwebrequest.getresponse ();
Stream Receivestream = Myhttpwebresponse.getresponsestream ();
StreamReader Readstream = new StreamReader (Receivestream, System.Text.Encoding.GetEncoding ("GB2312"));
This is the return result for the return value of the page to be fetched
returnvalue = Readstream.readtoend ();
More interested readers of asp.net related content can view the site topics: "asp.net operation JSON tips summary", "asp.net string operation tips Summary", "ASP.net Operation XML Skills summary", "asp.net file Operation skills Summary", " asp.net Ajax Skills Summary topic and the "ASP.net cache operation skills Summary."
I hope this article will help you to ASP.net program design.