title: How do I properly send __RequestVerificationToken with an ajax request in MVC5
body: <p>I'm trying to send an ASP.NET AJAX request to my application. In the application's controller, I have:</p>
  <pre><code>[HttpPost]
  [ValidateAntiForgeryToken]
  public async Task&lt;ActionResult&gt; Edit([Bind(Include = &quot;ID,Name,Instructions,Glass,Notes&quot;)] Drink drink,
      [Bind(Include= &quot;ID,Amount,Brand,IngredientID,DrinkID&quot;)] IEnumerable&lt;DrinkIngredient&gt; DrinkIngredients)
  {
      if (ModelState.IsValid)
      {
  //and so on
  </code></pre>
  <p>my javascript looks like this:</p>
  <pre><code>console.log($('#editDrinkForm').serialize())
  var x = new XMLHttpRequest();
  x = $.post(window.location,
      {
          data: $('#editDrinkForm').serialize()
      })
  .done(function () {
      console.log(&quot;done&quot;);
  })
  .fail(function () {
      console.log(x.responseText);
  })
  </code></pre>
  <p>and yet, I'm seeing this output:
  <img src="https://i.stack.imgur.com/5vEUp.png" alt="is too!" /></p>
  <p>You'll notice that <code>__RequestVerificationToken</code> is the first value! So what gives?</p>
  <h1>everything else</h1>
  <p>output transcription (from a later run)</p>
  <pre><code>&quot;__RequestVerificationToken=ZxW-JtClcOb-vYXDarYGYAEXtY84LzeiigiOKRhg4-sLSd1ixS4rwPtU-prisQ_D_vmoOYKP6cZ38ZTn5lhyg8Sh7V_F2VOgve6FkGNDOWcJy8JL8tEwPS7gy8uPd6Xl1_K8VdmWh6UGJBp372w8_w2&amp;ID=1&amp;Name=7%267&amp;DrinkIngredients.index=3&amp;DrinkIngredients%5B3%5D.ID=3&amp;DrinkIngredients%5B3%5D.DrinkID=1&amp;DrinkIngredients%5B3%5D.DrinkIngredientID=3&amp;DrinkIngredients%5B3%5D.Brand=Seagram's+7+crown&amp;DrinkIngredients%5B3%5D.ingredientID=2&amp;DrinkIngredients%5B3%5D.Amount=1+part&amp;DeleteDrinkIngredients.index=3&amp;DrinkIngredients.index=4&amp;DrinkIngredients%5B4%5D.ID=4&amp;DrinkIngredients%5B4%5D.DrinkID=1&amp;DrinkIngredients%5B4%5D.DrinkIngredientID=4&amp;DrinkIngredients%5B4%5D.Brand=7-up&amp;DrinkIngredients%5B4%5D.ingredientID=1&amp;DrinkIngredients%5B4%5D.Amount=4+parts&amp;DeleteDrinkIngredients.index=4&amp;Instructions=combine%2C+stir&amp;Glass=&amp;Notes=fff&quot;
  </code></pre>
  <p>(and)</p>
  <pre><code>&quot;&lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  
      &lt;head&gt;
  
          &lt;title&gt;The required anti-forgery form field &amp;quot;__RequestVerificationToken&amp;quot; is not present.&lt;/title&gt;
  
          &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width&quot; /&gt;
  
          &lt;style&gt;
  
           body {font-family:&quot;Verdana&quot;;font-weight:normal;font-size: .7em;color:black;} 
  
           p {font-family:&quot;Verdana&quot;;font-weight:normal;color:black;margin-top: -5px}
  
           b {font-family:&quot;Verdana&quot;;font-weight:bold;color:black;margin-top: -5px}
  
           H1 { font-family:&quot;Verdana&quot;;font-weight:normal;font-size:18pt;color:red }
  
           H2 { font-family:&quot;Verdana&quot;;font-weight:normal;font-size:14pt;color:maroon }
  
           pre {font-family:&quot;Consolas&quot;,&quot;Lucida Console&quot;,Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
  
           .marker {font-weight: bold; color: black;text-decoration: none;}
  
           .version {color: gray;}
  
           .error {margin-bottom: 10px;}
  
           .expandable { text-decoration:underline; font-weight:bold; color:&quot;[…]
  </code></pre>