2

Am receiving a JSON object from webservice in C# using the below script

    $.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 is a hidden feild.

On sucess am forwarding the Object to another aspx page and trying to deserialize this on page_load

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

Am I doing some thing wrong? as iam facing this error: Invalid JSON primitive: object

3
  • Can you show the class UserBO and the content of Request["hid"]? Commented Dec 16, 2011 at 21:11
  • it is a simple bo with get;set.like.... public class UserBO { public string userId { get; set; } public string userCode { get; set; }} Commented Dec 16, 2011 at 22:05
  • And the content of Request["hid"] ? Commented Dec 16, 2011 at 22:16

1 Answer 1

4

The "Invalid JSON primitive" error message means that whatever you're sending to the deserializer is not JSON. Have you verified that the value you're putting into the hidId field is valid JSON?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.