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

Ajax error on radimageeditor server side save

4 Answers 147 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Robby
Top achievements
Rank 1
Robby asked on 08 Jan 2014, 05:14 PM

Receiving the following error:

JavaScript runtime error: Sys.ArgumentException: Cannot deserialize empty string

Parameter name: data

The custom save javascript does the following:

var fileName = imageEditor.get_serverImageUrl();

imageEditor.saveImageOnServer(fileName, true);

The server-side code is as follows:


If e.FileName <> "" Then

   Dim img As ImageEditor.EditableImage = e.Image.Clone()

   Dim strFilePath As String = Server.MapPath(e.FileName)

   e.OverwriteFile = True

   img.Image.Save(strFilePath)







   e.Cancel = True

End If






4 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 13 Jan 2014, 05:18 PM
Hello Robby,

Such an error could be experienced if you are trying to save a big image when the ImageEditor is used in enabled CanvasMode. If this is the case, you can fix this by configuring the size of the allowed JSON string length:
<telerik:RadImageEditor ID="RadImageEditor1" runat="server" ImageUrl="Tulips.jpg">
    <EditableImageSettings MaxJsonLength="4097152" />
</telerik:RadImageEditor>
The value in the example is almost double the default value and you could go with it in your project, or increase it if needed.

In case this does not help in solving the case I will need to ask you for a sample project reproducing the issue, so we could examine it on our side.

Regards,
Veselina Raykova
Telerik
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 the blog feed now.
0
Josh
Top achievements
Rank 1
Veteran
answered on 28 Aug 2020, 04:39 PM

I was experiencing this same issue.  When using the server side ImageSaving event, it randomly would not fire when saving some images. I tried setting CanvasMode="No" as I found in other posts and I also tried increasing the MaxJsonLength.  It did not resolve it.  I then tried to implement my own save button to see if that would work.  So I implemented the button and used the javascript from other examples I found to send the request to the server.  This is nice because it makes the unneeded dialog go away.

                ie = $find("<%=MyImageEditor.ClientID %>");
                ie.saveImageOnServer("tempfile", true); // file, overwrite

This also did not work.  It would fail saying "cannot deserialize empty string".  

I also tried making my own server side button click event and inside that tried to get the image.   

        Dim foo As EditableImage = MyImageEditor.GetEditableImage()

This code would run server side but when I tried to GetEditableImage(), it failed saying "Illegal characters in path."

I was getting very frustrated, but I finally got it to work.  Previous posts had said to set CanvasMode="No".   I changed this from No to Automatic.  Suddenly everything worked as it should.  The random ImageSaving "event not firing" issue went away and also using my own server side code, I could now getEditableImage(), etc.   I hope this helps someone because I spent HOURS. For me it was the combination of setting CanvasMode="Automatic" and increasing the MaxJsonLength. 

0
Vessy
Telerik team
answered on 02 Sep 2020, 04:20 PM

Hi Josh,

Can you, please, confirm that you increased the maxJsonLenght both in imageEditor and on application level (in the web.config)?
https://docs.telerik.com/devtools/aspnet-ajax/controls/imageeditor/functionality/saving-large-images

<telerik:RadImageEditor RenderMode="Lightweight" ID="RadImageEditor1" CanvasMode="Yes" runat="server" ImageUrl="~/Images/image.jpg">
    <EditableImageSettings MaxJsonLength="2147483640" />
</telerik:RadImageEditor>

web.config
<configuration>
<system.web> <httpRuntime maxRequestLength="2147483640"/> </system.web> <system.web.extensions> <scripting> <webServices> <jsonSerialization maxJsonLength="2147483640"/> </webServices> </scripting> </system.web.extensions> </configuration>

Regards,
Vessy
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

0
Josh
Top achievements
Rank 1
Veteran
answered on 02 Sep 2020, 04:58 PM

Hi Vessy, 

Yes, I do have the maxJsonLength set in the webconfig as well.  It matches what I have set on the radimageeditor control.  If I change canvasmode property from "automatic" back to "No", it doesn't work again.  (Illegal characters in path)

Telerik_UI_for_ASP.NET_AJAX_2020_1_219_Dev_hotfix\Bin45\Telerik.Web.UI.dll

It's working for me to have canvasmode="Automatic"  so that is fine. In my case. 

Tags
ImageEditor
Asked by
Robby
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Josh
Top achievements
Rank 1
Veteran
Share this question
or