title: Moving information from a controller to a view
body: <p>I need to move data read from a database from a controller to a view and display it to a table. I can read from the database a store information to an object successfully, but I'm getting a <code>@foreach (var item in Model)</code> error when I run the page. Here is the method that reads the database:</p>
  
  <pre><code>public class DatabaseRead
  {
      public static async Task MongoReader(string path)
      {
          {
              MongoClient client = new MongoClient();
              var db = client.GetDatabase("POWA");
              var collection = db.GetCollection&lt;files&gt;("Imported");
              var filter = Builders&lt;files&gt;.Filter.Eq("quote_number", path);
              var result = await collection.Find(filter).ToListAsync();
              foreach (var results in result)
                  {
                      ContentDisplay read = new ContentDisplay();
                      read.product_name = results.product_name;
                      read.catalog_number = results.catalog_number;
                  }
          }
      }
  }
  </code></pre>
  
  <p>and here is my view:</p>
  
  <pre><code>@model List&lt;ProductionOrderWebApp.Controllers.ContentDisplay&gt;
  @{ ViewBag.Title = "Display"; }
  
  &lt;h2&gt;Order Table&gt;
  &lt;table board="1", style ="width:auto"&gt;
  &lt;tr&gt;
      &lt;th&gt;Item Name&lt;/th&gt;
      &lt;th&gt;Catalog Number&lt;/th&gt;
  &lt;/tr&gt;
  @foreach (var item in Model)
  {
  &lt;tr&gt;
      &lt;th&gt;@Html.Display(item.product_name);&lt;/th&gt;
  &lt;/tr&gt;
  }
  </code></pre>
  
  <p></p>
  
  <p>How can I get the table to display all the entries of the object without getting the error?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here is the code for my controller. All it does is call two methods, one to read a CSV file and write to mongo, and one that reads from the database and attempts to display the contents.</p>
  
  <pre><code>namespace ProductionOrderWebApp.Controllers
  pubic class Homecontroller : Controller
   {
      public ActionResult Index
      {
          return View();
      }
  
      public ActionResult Display()
      {
          return View();
      }
  
  
      [HttpPost]
      public async Task&lt;ActionResult&gt; Index(HttpPostedFileBase file)
  
      {
          if (file != null &amp;&amp; file.ContentLength &gt; 0)
          {
              var fileName = System.IO.Path.GetFileName(file.FileName);
              var path = System.IO.Path.Combine(("C:\\Dev\\ProductionOrderWebApp\\Uploads"), fileName);
              file.SaveAs(path);
              await CSVRead.CSVReader(path); //calls a method that reads and takes apart a CSV file
              await DatabaseRead.MongoReader(path);
  
          }
          return View("Display");
      }
  }
  </code></pre>
  
  <p>}</p>