title: How to receive data from ajax send() method in a controller
body: <p>I'm trying to serve the data in the ASP.NET MVC controller sent by ajax POST. On client side I use traditional XMLHttpRequest object and send() method instead of jQuery.ajax(). </p>
  
  <p>Do you know how to get variables from send() in controller? In documentation <a href="http://www.xul.fr/XMLHttpRequest-object.html" rel="nofollow">http://www.xul.fr/XMLHttpRequest-object.html</a> I've read that it has to be string. </p>
  
  <p>My client-side:</p>
  
  <pre><code>    var data1 = "some string";
      var data2 = "other string";
  
      var xhr = new XMLHttpRequest();
      xhr.open("POST", "https://localhost:44301/Home/SaveDataInDB", true);
      xhr.send(data1, data2);
      xhr.onreadystatechange = saved;
  </code></pre>
  
  <p>My server-side:</p>
  
  <pre><code>[HttpPost]
      public JsonResult SaveDataInDB(string data1, string data2) 
      {
          var dbobj = new DbObj
          {                
              field1 = data1,
              field2 = data2
          };
  
          if (User.Identity.IsAuthenticated)
          {
              dbobj.user = User.Identity.Name;
          }
          else 
          {
              dbobj.user = "anonymous";
          }
  
  
          db.DbObj.Add(dbobj);
          db.SaveChanges();
  
          return Json(true);
      }
  </code></pre>