javascript - Pass PNG on form submit, Request URL Too long -


so have interesting question. have form user draws image on canvas (think signature pad). need send image c# controller (i using asp.net mvc 5). code have functions shorter strings, when try pass png data, long , recieve http error 414. request url long error. here code:


html:

<form id="mainform" action="submituseranswer" method="post">     <input type="hidden" id="useroutput" name="output" value="" />     //...other form elements, signature box, etc. </form> 

javascript:

function gotonextquestion() {     var output = $('#signature').jsignature("getdata");         $('#useroutput').val(output);         $('#mainform').submit(); } 

c#:

public actionresult submituseranswer()     {         //use useroutput whatever         //submit string database, trigger stuff, whatever         //go next question         system.collections.specialized.namevaluecollection nvc = request.form;         string useroutput = nvc["output"];         viewbag.question = useroutput;         return redirecttoaction("redirecttoindex", new { input = useroutput });     }      public actionresult redirecttoindex(string input)     {          viewbag.answer = input;         return view("index");     } 

my png data long, error makes sense. question how can png data controller?

maybe need increase allowed request url length.

if doesn't works have aspx webform saves signature, , use webmethod

[scriptmethod, webmethod] public static string savesignature(string data) {     /*..code..*/ } 

and call this:

pagemethods.savesignature(document.getelementbyid('canvas').todataurl(), onsucess, onerror); 

also have increase length of json request , works fine, no problems lenght.

in mvc there isn't webmethods, json , ajax requests job, save data in session variable, , use when need it.

hope helps


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -