gpt4 book ai didi

c# - 无效的 JSON 原语 : object : Passing Object as a Parameter from aspx

转载 作者:行者123 更新时间:2023-11-30 21:10:21 25 4
gpt4 key购买 nike

正在使用以下脚本在 C# 中从 Web 服务接收 JSON 对象

    $.ajax({
type: "POST",
url: "Services/LogService.asmx/authenticateLogin",
data: "{'gopId':'" + txtGopId+ "'}",
contentType: "application/json; charset=utf-8",
success: function (response)
{
var k = $("#hidId").val(response.d);
window.location.replace("Pages/Reved.aspx?hid="+k+"");
},
error: function (xhr, status, error) {

DisplayError(xhr);
}
});

hidId 是一个隐藏字段。

成功时我将对象转发到另一个 aspx 页面并尝试在 page_load 上反序列化它

         JavaScriptSerializer serializer = new JavaScriptSerializer();
userBO = serializer.Deserialize<UserBO>(Request["hid"]);

我做错了什么吗?因为我面临这个错误:无效的 JSON 原语:对象

最佳答案

“无效的 JSON 原语”错误消息意味着您发送到反序列化器的任何内容都不是 JSON。您是否已验证您输入 hidId 字段的值是有效的 JSON?

关于c# - 无效的 JSON 原语 : object : Passing Object as a Parameter from aspx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8539751/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com