作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
正在使用以下脚本在 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/
我是一名优秀的程序员,十分优秀!