If a web address contains Chinese characters, the browser automatically converts it to A URL encoding, and on the receiving end, it automatically converts back.

 

Most of the time it’s fine, but sometimes it’s annoying. Because this KIND of URL encoding is generated, the encoding character set may not be the same as the decoding character set. For example, GB2312 is used for encoding and UTF-8 is used for decoding, so garbled characters appear.

 

At this point, the extracted parameters, of course, chaos.

 

The solution is to use Request.rawURL instead of Request.QueryString. The latter is the original URL, not automatically decoded. Get it and deal with it.

 

\

//scode = Request.QueryString[“word”]; \

int p = Request.RawUrl .IndexOf(“word=”);

string scode = Request.RawUrl.Substring(p + 5);