This is a migrated thread and some comments may be shown as answers.

Error - Invalid JSON primitive

1 Answer 211 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Srini
Top achievements
Rank 1
Srini asked on 05 Jul 2012, 12:45 PM

Hi,

I have an error when clicking a button or Changing Radcombo in a JQuery popup

I am using Updatepanel with RadAjaxManager.

The stack of the error message is:

Stack Trace:

[ArgumentException: Invalid JSON primitive: {"enabled":true,"emptyMessage":"","minValue":1,"maxValue":70368744177664}.]
   System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer) +561472
   System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) +44
   System.Web.Script.Serialization.JavaScriptSerializer.DeserializeObject(String input) +13
   Telerik.Web.UI.RadWebControl.LoadPostData(String postDataKey, NameValueCollection postCollection) +136
   Telerik.Web.UI.RadInputControl.LoadPostData(String postDataKey, NameValueCollection postCollection) +50
   Telerik.Web.UI.RadWebControl.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +42
   System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +327
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +878


I appreciate the help.
Alejandro Espina
Top achievements
Rank 1
commented on 27 Jun 2023, 03:55 PM

I get the same error, but on RadButton.LoadPostData.  As the error is very random and never seen in debug mode, and there are so many radbuttons on my screen, I'd like to Ask how to Catch this error (in Application_Error event?) so that we can see which button and what input string looks like.

Thanks,

 

Tony

Rumen
Telerik team
commented on 28 Jun 2023, 02:49 PM

Hi Tony,

The Invalid JSON primitive err is usually caused by the inability of the JavaScriptSerializer to deserialize the client-state object of the control. It may be possible that you have used some special/invalid symbols in the value of a property set on the client, so that it cannot be deserialized later on the sever. You must ensure that is not the case.
You can try to set the ValidateRequest propery to false in the page directive. This may prevent the error from showing up but will not examine any other dangerous input values from the browser.
Can you ensure that there aren't any dynamically loaded controls with ClientIDMode property set to "Static"?

Generally, such an error can come from a variety of places and similar issues have been caused by things like special symbols in control values (like text, value, command names, etc.) or by third parties tampering with the request (browser add-on or extension, proxies, firewalls, server modules, antivirus software, etc.).

Other reasons we have seen for such errors is a wrong control tree on the server that attempts to load the POST data. This happens when controls are not properly created (either in the markup, or in Page_Init) with the same IDs each time. In one case the ID of the button object matched another object in the page and that caused the issue.

Also, if you are changing some properties server-side before the post data is applied to the control.

You can try to catch the error in the Application_Error event (try Exception ex = Server.GetLastError();) or check the Windows server event logs.

1 Answer, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 10 Jul 2012, 11:29 AM
Hi,

Could you share the exact implementation used so we could examine it?

Greetings,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
General Discussions
Asked by
Srini
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or