title: Can't Send Base64 string To C# via AJAX
body: <p>I am simply sending a base64 string thru ajax to an aspx page with C# code behind. The string never makes it to the C#. It always comes out empty.</p>
  
  <p>The ajax is being sent in the post request and all other form fields post fine.</p>
  
  <p>My string looks like: <code>QmFzZSA2NCDigJQgTW96aWxsYSBEZXZlbG9wZXIgTmV0d29yaw==</code></p>
  
  <p>The method that sends the string to c# code behind is:</p>
  
  <pre><code>string signature = Request.Form.Get("newsig");
  var pdfContents = PDFHelper.GeneratePDF(pdfPath, formFieldMap, signature);
  </code></pre>
  
  <p>The code behind:</p>
  
  <pre><code>string base64image = sig;
  //  Convert base64string to bytes array
  var newbytes = Convert.FromBase64String(base64image);
  </code></pre>
  
  <p>Sometimes the base64 string is long - could this be the issue? Is there a better way of handling base64 strings in c#?</p>
  
  <p>UPDATE: my ajax post method:</p>
  
  <pre><code>    var localbase64string = localStorage["signature"];
      var b64 = localbase64string.replace(/^data:image\/(png|jpg);base64,/, "");
  
      var formData = new FormData($(this)[0]);
      formData.append( 'newsig', b64);
  
      var sendPost = 'http://xxx.xx/this.aspx';
  
      $.ajax({
          type: 'POST',
          data: formData,
          processData: false,
          contentType: false,
          timeout: 50000,
          url: sendPost,
          success: function(data){
              alert('Sent!');
              window.location.href = './../mainmenu.html';
  
         }, error:function (){  
                      alert("something went wrong!");
          }
  
      });
  </code></pre>