title: Using ViewData to pass data from Controller to View
body: <p>I'm trying to pass data from a controller to view, and display these data. But after many tries I can't.</p>
  
  <p>Controller code : </p>
  
  <pre><code>public ActionResult ValidSearch(ProductSearchParam gp)
  {
  
      if (gp.IsCandidate)
      {
          ViewBag.abc="bob";
          List&lt;ProductCandidate&gt; prodClist = new List&lt;ProductCandidate&gt;();
          prodClist = Pcs.SearchParam(gp,0,100);
          ViewBag.total = prodClist.Count;
          return View("ValidSearchCandidate", prodClist);
      }
      else
      {
          List&lt;Product&gt; prodlist = new List&lt;Product&gt;();
          prodlist = Ps.SearchParam(gp,0,100);
          ViewBag.total = prodlist.Count;
          return View("ValidSearch", prodlist);
      }
  
      //return View();
  }
  </code></pre>
  
  <p>View code : </p>
  
  <pre><code>&lt;body&gt;
      &lt;div&gt;
  
          &lt;p&gt;Bonjour @ViewBag.abc&lt;/p&gt;
  </code></pre>
  
  <p>I've even try <code>TempData</code> or <code>ViewBag</code>, unsuccessfully.</p>
  
  <p>I do not understand why the value is not getting passed to the View correctly
  Can someone help me to solve this ?</p>