[转]建行B2B支付回调参数乱码现象解析
时间:2011-03-03 来源:独钓寒江
问题是这样出现的:在进行建行B2B网银在线支付时,建行在回调时采用POST方式提交,编码方式为GBK,而我们的系统为ASP.NET,编码UTF-8。通过Request获取的参数是乱码。
题是这
解决办法:从InputStream解析,获取参数。具体代码如下:
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 }
相关阅读 更多 +