JsonResult 通过安全连接出现乱码

发布于 2025-01-01 00:38:25 字数 1404 浏览 1 评论 0原文

我正在尝试构建一个 Web 服务来与需要安全连接的移动应用程序进行交互。

通过不安全的连接,我从服务器获取所需的 JSON 结果,并可以构建适当的 JSON 对象(在测试设备上)。

期望的 JSON 结果是:

{"memberID":"999999","statusCode":"0","message":"Your member information has been processed, please confirm to continue with payment.","total":"66.66"}

但是,使用安全连接,控制器返回:

ur member information has been processed, please confirm to continue with payment.","total":"66.66"}

服务器端代码现在很简单:

[HttpPost]
public JsonResult startTransaction( FormCollection form ) {
    // process form values
    Dictionary<string,string> result = new dictionary<string,string>();
    result.Add("memberID","999999");
    result.Add("statucCode","0");
    result.Add("message","Your member information has been processed, please confirm to continue with payment.");
    result.Add("total","66.66");

    return Json(result);
}

如果它对设备端(Android)上的开发有帮助,我接受 的所有证书https

我不确定响应是如何以这种方式缩短的。

更新:

尝试了 Fiddler2、Firebug 和 JSONView 后,我似乎仍然无法解决该错误。

读取响应的代码(在 Android 设备上)是:

responseStream = connection.getInputStream();
int bytesRead = -1;
byte[] buffer = new byte[8*1024];

while( (bytesRead = responseStream.read(buffer)) >= 0 ) {}

response = new String( buffer );

我认为缓冲区太小,但事实并非如此,因为我尝试过更大的缓冲区大小。

I am trying to build a web service to interact with a mobile application that requires a secure connection.

Over an unsecured connection, I get the desired JSON Result from the server and can build the approprioate JSON object (on the test device).

The desired JSON result is:

{"memberID":"999999","statusCode":"0","message":"Your member information has been processed, please confirm to continue with payment.","total":"66.66"}

However, using a secure connection, the controller returns:

ur member information has been processed, please confirm to continue with payment.","total":"66.66"}

The server side code is simple for now:

[HttpPost]
public JsonResult startTransaction( FormCollection form ) {
    // process form values
    Dictionary<string,string> result = new dictionary<string,string>();
    result.Add("memberID","999999");
    result.Add("statucCode","0");
    result.Add("message","Your member information has been processed, please confirm to continue with payment.");
    result.Add("total","66.66");

    return Json(result);
}

If it helps, for development, on the device side (Android), I am accepting all certificates for https.

I am not sure how the response is getting shortened in such a way.

UPDATE:

After trying Fiddler2, Firebug, and JSONView, I still can't seem to resolve the error.

The code (on the Android device) where the response is read is:

responseStream = connection.getInputStream();
int bytesRead = -1;
byte[] buffer = new byte[8*1024];

while( (bytesRead = responseStream.read(buffer)) >= 0 ) {}

response = new String( buffer );

I thought the buffer was too small, but that is not the case, since I have tried larger buffer sizes.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

窝囊感情。 2025-01-08 00:38:25

我会尝试 Fiddler 或 Firebug 来执行 HTTPS 请求,看看结果是什么。这样您就可以找出问题是在服务器上还是在客户端上。

I would try Fiddler or Firebug to perform the HTTPS request and see what the result is. This way you could find out if the problem is on the server or on the client side..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文