title: Why isn't viewbag value passing back to the view?
body: <p>straight forward question , can't seem to get my viewBag value to display in a view that the user is directed to after completing a form.</p>
  
  <p>Please advise..thanks</p>
  
  <p>My Index ActionResult simple returns model data..</p>
  
  <pre><code>public ActionResult Index()
  {
      var source = _repository.GetByUserID(_applicationUser.ID);
      var model = new RefModel
      {
          test1 = source.test1,
      };
      return View(model);
  }
  </code></pre>
  
  <p>My Get Edit" ActionResult , simply uses the same model data as Index.</p>
  
  <p>My Post "Edit" ActionResult, assigns the new values if any to the model and redirects to the Index page, but Index page does not display ViewBag value ??</p>
  
  <pre><code>[HttpPost]
  public ActionResult Edit(RefModell model)
  {
      if (ModelState.IsValid)
      {
          var source = _repository.GetByUserID(_applicationUser.ID);
          if (source == null) return View(model);
  
          source.test1 = model.test1;
          _uow.SaveChanges();
  
          @ViewBag.Message = "Profile Updated Successfully";
          return RedirectToAction("Index");      
      }
      return View(model);
  }
  </code></pre>
  
  <p>And in my Index view...</p>
  
  <pre><code>@if(@ViewBag.Message != null)
  {
      &lt;div&gt;
          &lt;button type="button"&gt;@ViewBag.Message&lt;/button&gt;
      &lt;/div&gt;
  }
  </code></pre>