Connection: http://web.cnzer.cn/html-12174-1.html
The problem arises as follows: During the online payment of B2B Online Banking of China Construction Bank, China Construction Bank uses the POST method for callback and the encoding method is GBK, while our system is ASP. NET, encoding UTF-8. Parameters obtained through Request are garbled.
Question:
Solution: retrieve parameters from InputStream resolution. The Code is as follows:
1 IServiceProvider provider = (IServiceProvider) HttpContext. Current;
2 HttpWorkerRequest worker = (HttpWorkerRequest) provider. GetService (typeof (HttpWorkerRequest ));
3 byte [] bs = worker. GetQueryStringRawBytes ();
4 String queryString = Encoding. GetEncoding ("GBK"). GetString (bs );
5 NameValueCollection querys = HttpUtility. ParseQueryString (queryString );
6 if (querys! = Null & querys. Count> 0)
7 {
8 foreach (String key in querys. AllKeys)
9 {
10 if (key = "ACC_NAME ")
11 {
12 ACC_NAME = querys [key];
13}
14
15 if (key = "BRANCH_NAME ")
16 {
17 BRANCH_NAME = querys [key];
18}
19}
20}