title: Getting User Input with ASP.NET Core MVC
body: <p>I am trying to use ASP.NET MVC to get user input via <code>Html.BeginForm()</code> and display what the user inputted on the same page/view. The issue im having is after the user hits submit, the data does not show.</p>
  <p>Here's how my project is set up,
  In <code>Index.cshtml</code>:</p>
  <pre><code>@model SynNetTest.Models.HomeModel
  @{
      ViewData[&quot;Title&quot;] = &quot;Home Page&quot;;
      Layout = &quot;~/Views/Shared/_Layout.cshtml&quot;;
  }
  
  &lt;div class=&quot;text-center&quot;
      &lt;h2&gt;The current directory: @Model.directory&lt;/h2&gt;
      &lt;h3&gt;@Model.Load()&lt;/h3&gt;
  
      @using (Html.BeginForm(&quot;Index&quot;, &quot;Home&quot;, FormMethod.Post))
      {
          &lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;
              &lt;tr&gt;
                  &lt;th colspan=&quot;2&quot; align=&quot;center&quot;&gt;Word Details&lt;/th&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Enter Word: &lt;/td&gt;
                  &lt;td&gt;
                      @Html.TextBoxFor(m =&gt; m.word)
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      }
      &lt;h4&gt;The word entered: @Model.word&lt;/h4&gt;
  &lt;/div&gt;
  </code></pre>
  <p>In <code>HomeModel.cs</code>:</p>
  <pre><code>public class HomeModel
      {
          public string directory { get; set; }
          public WordNetEngine wordNet { get; set; }
          public string word { get; set; }
          public List&lt;SynSet&gt; synSetList { get; set; }
  
          //load words to access
          public string Load()
          {
              wordNet.AddDataSource(new StreamReader(Path.Combine(directory, &quot;data.adj&quot;)), PartOfSpeech.Adjective);
        
              wordNet.Load();
              return &quot;Database Loaded Successfully&quot;;
  
          }
      }
  </code></pre>
  <p>In <code>HomeController.cs</code>:</p>
  <pre><code>    public class HomeController : Controller
      {
          public IActionResult Index()
          {
              var home = new HomeModel()
              {
                  directory = Directory.GetCurrentDirectory(),
                  wordNet = new WordNetEngine(),
              };
              return View(home);
          }
  
  
          [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
          public IActionResult Error()
          {
              return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
          }
      }
  }
  </code></pre>
  <p>I am working with the Syn.WordNet NuGet package to try to get the definitions of words that the user enters to print out. So far, Im just trying to see if the input can be processed and put on the same page/view.</p>