title: Asp .Net Core 2.2 Razor Pages Ajax Call Post not working
body: <p>I've done so many ajax in razor pages but i can't figure out why this does not work. It keeps giving me error 400 on dev tools. It does not reach the page handler no matter what.</p>
  
  <pre><code>&lt;script&gt;
       $.ajax({
                      url: "/Account/Users/Index?handler=Delete",
                      type: "POST",
                      data: {
                          id: id
                      },
                      success: function () {
                          swal("Utilizador Desactivado!", {
                              icon: "success",
                          });
                      },
                      error: function (xhr, ajaxOptions, thrownError) {
                          swal("Falha na ligação ao servidor. Tente novamente mais tarde.");
                      }
                  });
  &lt;/script&gt;
  </code></pre>
  
  <p>page handler </p>
  
  <pre><code>  public async Task&lt;IActionResult&gt; OnPostDeleteAsync(int? id)
      {
          if (id == null)
          {
              return NotFound();
          }
  
          var user = await _context.Users.FindAsync(id);
  
          if (user != null)
          {
              user.IsActivo = false;
              _context.Users.Attach(user).Property( u =&gt; u.IsActivo).IsModified = true;
              await _context.SaveChangesAsync();
          }
  
          return RedirectToPage("./Index");
      }
  </code></pre>
  
  <p>I tried many url combinations and none work. I don't see what is wrong in here....</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>It seems like the problem is the anti forgery token not being validated on razor page.</p>
  
  <p>I wrote Ignore Anti forgery Token on the page model and everything works correctly</p>