title: MVC3 Razor - using viewbag in controller and view
body: <p>I am trying to create dynamic properties for my viewbag based on an if/else condition in my controller. What the viewbag displays will depend on my logic in the controller. In my view I try to call my viewbag with razor syntax but nothing renders to the page.</p>
  
  <pre><code>[HttpPost]
          public ActionResult EditUser(vw_UserManager_Model edituser)
          {
              UserManager.Models.vw_UserManager_Model model = edituser; 
              int outcome = 0;
                  outcome = UserManager.DAL.EditUser(model);
                  if (outcome == 1)
                  {
                      ViewBag.Message = "Successfully edited user" + model.UserName;
                      ViewBag.Description = "Look below for full details.";
                      //ViewData["Message"] = "Successfully edited user" + model.UserName;
                      return RedirectToAction("showSuccess", model);
                  }
                  else
                  {
                      ViewBag.Message = "Failure";
                      return RedirectToAction("showFailure", model);
                  }
          }
  
  #region successErrorHandling
          public ActionResult showError(List&lt;string&gt; ErrorMessage)
          {
              ViewBag.ErrorMessage = ErrorMessage[0];
              return View("ErrorMessageView");
          }
  
          public ActionResult showSuccess(vw_UserManager_Model model)
          {
  
              return View("SuccessMessageeView", model);
          }
  </code></pre>
  
  <p>I set two properties for viewbag, message and description. I do a redirect if successful or failure.</p>
  
  <pre><code>@model UserManager.Models.vw_UserManager_Model
  &lt;h2&gt;@ViewBag.Message&lt;/h2&gt;
  &lt;br /&gt;
  &lt;h4&gt;@ViewBag.Description&lt;/h4&gt;
  &lt;h2&gt;
      SuccessMessageeView&lt;/h2&gt;
  &lt;br /&gt;
  User Created:
  @using (Html.BeginForm())
  {
      &lt;ul&gt;
          &lt;li&gt; &lt;b&gt;@Html.Label("Username:  ")&lt;/b&gt;@Model.UserName&lt;/li&gt;
          &lt;li&gt; &lt;b&gt;@Html.Label("Salutation:  ")&lt;/b&gt;@Model.salutation&lt;/li&gt;
          &lt;li&gt; &lt;b&gt;@Html.Label("Firstname:  ")&lt;/b&gt;@Model.firstname&lt;/li&gt;
          &lt;li&gt;  &lt;b&gt;@Html.Label("Lastname:  ")&lt;/b&gt;@Model.lastname&lt;/li&gt;
          &lt;li&gt; &lt;b&gt;@Html.Label("Email:  ")&lt;/b&gt;@Model.email&lt;/li&gt;
          &lt;li&gt; &lt;b&gt;@Html.Label("Group name:  ")&lt;/b&gt;@Model.group_name&lt;/li&gt;
          &lt;li&gt; &lt;b&gt;@Html.Label("Is active:  ")&lt;/b&gt;@Model.isactive&lt;/li&gt;
      &lt;/ul&gt;
  }
  </code></pre>
  
  <p>In my view I then call my viewbag but it doesn't render. Am I doing this incorrectly?</p>