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
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.
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
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.