Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi,
I am trying to save Base64 data in to database.
But I am not able to send dataUrl to my .asmx file.

Jquery
JavaScript
function UploadUserPhoto() {                
    var Mycanvas = document.getElementById("tempCanvas");
    var dataURL = Mycanvas.toDataURL("image/png");               
                
    $.ajax({
        url: "LP18WS.asmx/UploadPhoto",
        contentType: "application/json; charset=utf-8",
        data: {
            Base64String: "\'" + dataURL + "\'"
        },
        dataType: "json",
        success: function (msg) {
            alert(msg.d);
        },
        error: function (msg) {
            alert(msg + '\n' + xhr.responseText);
        },
    });
}

Webservice (LP18WS.asmx)
C#
[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json,  UseHttpGet = true)]
public string UploadPhoto(string Base64String)
{
   string message = "";
    //code to save data url in database            
   return message;
}

But it is not sending the dataurl. If I put some other string instead of dataurl it is working.
Why this dataurl can't send?. Can any one guid me?

I have observed that it is happening when there are large amount of data within dataURL. Otherwise when the amount of data is minimum it is working. Can you give me a solution to overcome this situation.
Posted
Updated 25-Apr-13 5:13am
v3
Comments
Prasad Khandekar 25-Apr-13 11:15am    
Don't use GET, use Post to sending large data. Query string length is generally limited to few kbs.
SHAJANCHERIAN 27-Apr-13 9:46am    
Thank you. Its working..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900