title: Why i receive a NullReference Exception in TempData
body: <p>i'm new in Asp Net and i have some questions. So i make an example to understand, this example return a tempData with the match name in the List. The List has 3 objects created in the actionResult Index. </p>
  
  <pre><code>   [HttpPost]
      public ActionResult Buscar(String NomeP)
      {
          int i;
          List&lt;Models.Produto&gt; Lista = null;
  
          Lista = Session["SSLista"] != null ? (Session["SSLista"] as List&lt;Models.Produto&gt;) : new List&lt;Models.Produto&gt;();
          for (i = 0; i&lt; Lista.Count; i++) {
              if (Lista[i].Nome.Equals(NomeP)) {
                  TempData["Found"] = Lista[i];
              }
          }
        return RedirectToAction("Produto", "Home");
  </code></pre>
  
  <p>}</p>
  
  <p>When i try to show the return i receive this exception of NUllReference, but the tempData has some data in return. </p>
  
  <p>&lt;% Html.EndForm();  %>
       &lt;% </p>
  
  <pre><code>if (TempData["Found"] != null)
  { %&gt;
  &lt;% 
  foreach (var prod in (TempData["Found"] as List&lt;MvcApplication2.Models.Produto&gt;))
  {
  %&gt;
  &lt;br /&gt;
  &lt;h2&gt;Produtos&lt;/h2&gt;
  &lt;label&gt;
     Nome: &lt;%=prod.Nome %&gt;
  &lt;/label&gt;
   &lt;label&gt;
     Descrição &lt;%= prod.Descricao%&gt;
  &lt;/label&gt;
   &lt;label&gt;
     Preço: &lt;%= prod.Valor_unitario%&gt;
  &lt;/label&gt;
   &lt;label&gt;
     ID: &lt;%= prod.Id%&gt;
  &lt;/label&gt;&lt;br&gt;
  &lt;% }
  }
  </code></pre>
  
  <p>The image below show's that Tempdata has some Data, but i can convert in the foreach. </p>