title: MVC Viewbag passing list to view
body: <p>sWhat is wrong with this code? I'm just trying to practice passing a list to my view:</p>
  
  <p>Controller:</p>
  
  <pre><code>public ActionResult About()
  
      {
          List&lt;string&gt; ListofColors = new List&lt;string&gt;();
          ViewBag.colors.Add("red");
          ViewBag.colors.Add("green");
          ViewBag.colors.Add("blue");
  
          ViewBag.ListColors = ListofColors;
          return View();
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;ul id="colors"&gt;
  
  @foreach (var colors in (List&lt;string&gt;) ViewBag.ListColors) { 
  &lt;li&gt;
      @colors
  &lt;/li&gt;
  } 
  
  &lt;/ul&gt;
  </code></pre>
  
  <p>The error I get is:CS0103: The name 'colors' does not exist in the current context</p>