title: Accessing the property of a model in ASP.NET MVC View
body: <p>I am having problems accessing one of the properties of the model I am passing a View. </p>
  
  <p>The model is defined like this:</p>
  
  <pre><code>public class ProductBasket
  {
      public ProductBasket()
      {
          Products = new List&lt;ProductConfiguration&gt;();
          Errors = new List&lt;string&gt;();
      }
      public List&lt;ProductConfiguration&gt; Products { get; set; }
      public List&lt;string&gt; Errors { get; set; }
  }
  </code></pre>
  
  <p>In my view the model directive is declared like this:</p>
  
  <pre><code>@model MyApp.ViewModels.Product.ProductBasket
  </code></pre>
  
  <p>I am unable to access the <code>Products</code> property in a <code>foreach</code> loop. In VisualStudio when I hover of the <code>Model</code> variable in the loop it shows:</p>
  
  <pre><code>List&lt;MyApp.ViewModels.Product.ProductConfiguration&gt; 
  WebViewPage&lt;List&lt;MyApp.ViewModels.Product.ProductConfiguration&gt;&gt;.Model { get; }
  </code></pre>
  
  <p>This is the <em>previous</em> model I was using - I don't know why this is there?</p>
  
  <p><strong>What I have done</strong></p>
  
  <p>Instinct tells me I should be able to access the Products property with <code>Model.Products</code> (please tell me if this is incorrect), but I don't understand why the view isn't being passed a <code>ProductBasket</code>?</p>