title: asp.net core post method, tag helpers and query string
body: <p>I'm getting this unexpected behavior from asp.net core which I'm starting to learn.</p>
  
  <p>I have a below form in my View:</p>
  
  <pre><code>&lt;form asp-controller="Account" asp-action="Login" method="post"&gt;
      &lt;button type="submit"&gt;LOGIN&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Yes I'm using tag helpers here. And here is the controller:</p>
  
  <pre><code>public class AccountController : Controller
  {
      [HttpPost]
      [AllowAnonymous]
      public async Task&lt;IActionResult&gt; Login(string returnUrl)
      {
          if (string.IsNullOrEmpty(returnUrl) || !Url.IsLocalUrl(returnUrl))
                      return RedirectToAction("index", "home");
                  else
                      return LocalRedirect(returnUrl);
      }
  
  }
  </code></pre>
  
  <p>Now as per my understanding thus far, returnUrl should automatically get query string value if it is there in query string. But with this setup it is not happening. After a lot of head scratching I found a solution online to change  in my view into this:</p>
  
  <pre><code>&lt;form method="post"&gt;
      &lt;button type="submit"&gt;LOGIN&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and then it starts working. But why is this behavior there, what is causing this, why form tag helpers not letting query string to bind for this post method form ???</p>