title: Populate Form Fields after Submit ASP.NET Core 3.1 MVC
body: <p>I am trying to repopulate my input fields after the form has been submitted (with HttpPost). Is there a simple way to do this? I have a dropdown and a text box that get populated with data from the database. They each have their own functions in the controller that handle the flow of data. My goal is to have the last created data appear in the input fields after submit.</p>
  <p>My Model</p>
  <pre><code>public int ID { get; set; }
  public string bookName { get; set; }
  public string Author { get; set; }
  </code></pre>
  <p>My View</p>
  <pre><code>&lt;form method=&quot;post&quot; asp-controller=&quot;Home&quot; asp-action=&quot;Home&quot; role=&quot;post&quot;&gt;
      &lt;div class=&quot;form-group&quot;&gt;
          &lt;label asp-for=&quot;bookName&quot;&gt;&lt;/label&gt;
          &lt;select name=&quot;bookName&quot; asp-items=&quot;@(new SelectList(ViewBag.message, &quot;ID&quot;, &quot;bookName&quot;))&quot;&gt;
  &lt;/select&gt;
      &lt;/div&gt;
      &lt;div class=&quot;form-group&quot;&gt;
          &lt;label asp-for=&quot;Author&quot;&gt;&lt;/label&gt;
          &lt;input asp-for=&quot;Author&quot; class=&quot;form-control&quot; /&gt;
      &lt;/div&gt;
      &lt;div class=&quot;form-group&quot;&gt;
          &lt;input type=&quot;submit&quot; value=&quot;Submit&quot; class=&quot;btn btn-primary&quot; /&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  <p>My Controller</p>
  <pre><code>        public void GetBooksDDL()
          {
              List&lt;BookModel&gt; bookName = new List&lt;BookModel&gt;();
              bookName = (from b in _context.BookModel select b).ToList();
              bookName.Insert(0, new BookModel { ID = 0, bookName = &quot;&quot; });
              ViewBag.message = bookName;
          }
  
          [HttpPost(&quot;[action]&quot;)]
          [Route(&quot;/Home&quot;)]
          [Produces(&quot;application/json&quot;)]
          public async Task&lt;IActionResult&gt; Home()
          {
              if (textbox != &quot;&quot;)
              {
                  //do all the submit actions
                  //after all of the actions are complete return the view:
                  GetBooksDDL();
                  return View();
              }else
              {
                  return Error;
              }
          }
  </code></pre>
  <p>I understand that I could pass in the model in the View(), but the values are always null. I tried to pass in my (BookModel model) as an argument in the HttpPost, but I get a 415 status.</p>