title: How to pass a viewbag with RedirectToAction
body: <p>I got a controller which assign a value to the <code>ViewBag</code> and that <code>ViewBag</code> is used in the script,</p>
  
  <p>this is my code, i have no idea whats wrong, i even tried using <code>TempData</code> but nothing happens everytime it shows that my <code>ViewBag</code> is null.</p>
  
  <pre><code>public ActionResult ChechUserNP(Login dd)
  {
      if (dd.userid == "admin" &amp;&amp; dd.pwd == "admin")
      {
          return RedirectToAction("Index", "DataGridView");
      }
      else
      {
          @ViewBag.Message = "MyMessage";
          return RedirectToAction("Index", "Login");
      }
  }
  </code></pre>
  
  <pre><code>&lt;script&gt;
      debugger;
      if (@ViewBag.Message !== null) {
      }
  &lt;/script&gt;
  </code></pre>