locked
POST BASE64 to Default.aspx/upload ex. RRS feed

  • Question

  • User1549730113 posted

    Hi,
    I want to POST BASE64 to "Default.aspx/Upload" in order to save in SQL Server Database via AJAX!?
    I post it to the page but I can not catch it!?

    ExceptionType:"System.ArgumentException"

    Message:"Error during serialization or deserialization using the JSON JavaScriptSerializer. "


    Front:
    Fr.voice.export(function (url) {
    console.log("Here is the base64 URL : " + url);
    $.ajax({
    url: "Chat.aspx/Upload",
    type: 'POST',
    data: '{data: "' + url + '"}',
    contentType: 'application/json; charset=utf-8',
    dataType:'json',
    success: function (msg) {
    alert("ok");
    }
    });
    }, "base64");

    Behind:
    [System.Web.Services.WebMethod]
    public static string Upload(string data)
    {
    return (data);
    }
    "ASP.Net |C# |WebForms |Empty Project"

    Thanks

    Thursday, August 2, 2018 8:32 AM

All replies

  • User753101303 posted

    Hi,

    What if you try "data":"value" rather than just data:"value". AFAIK json requires the name to be enclosed as well within ".

    If confirmed you could also consider to stop building manually json strings (for example it could seem to work but fail as soon as someone will use a character that needs to be escaped). Using JSON.stringify on an object is likely better.

    Thursday, August 2, 2018 9:46 AM