Pass PNG on form submit, Request URL Too long

后端 未结 2 914
一整个雨季
一整个雨季 2021-01-15 21:51

So I have an interesting question. I have a form where a user draws an image on a canvas (think a signature pad). I then need to send the image to my C# Controller (I am usi

2条回答
  •  被撕碎了的回忆
    2021-01-15 21:55

    Maybe you just need to increase allowed GET request URL length.

    If that doesn't works I have an aspx WebForm that saves a signature, and I use a WebMethod

    [ScriptMethod, WebMethod]
    public static string saveSignature(string data)
    {
        /*..Code..*/
    }
    

    and I call it like this:

    PageMethods.saveSignature(document.getElementById('canvas').toDataURL(), onSucess, onError);
    

    also I have to increase the length of the JSON request and it works fine, with no problems with the lenght.

    In MVC there isn't WebMethods, but JSON and AJAX requests do the job, just save the data in a session variable, and then use it when need it.

    Hope it helps

提交回复
热议问题