title: TempData only displaying in child partial view, not parent partial view
body: <p>I am creating an MVC mini app within an Umbraco web page.  I've asked questions in the Umbraco user forums but so far have not gotten a solution.</p>
  
  <p>My Umbraco 6.1.6 site has a webForms MasterPage(s).  On my content page is a rich text editor in which I place a macro.  That macro loads a Macro Partial View which looks like this:</p>
  
  <pre><code>&lt;p&gt;&lt;span style="color: red;"&gt;@TempData["CustomMessage"]&lt;/span&gt;&lt;/p&gt;
  
  @Html.Partial("~/Views/MacroPartials/Admin/Ethics/_Opinions.cshtml")
  &lt;br /&gt;
  &lt;input type="button" value="Add a New Opinion" class="btn btn-default" onclick="OpenCreatePopup()" /&gt;
  
  &lt;div id="opinionEditForm"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>The @Html.Partial loads a jQuery grid of records.  Each has an edit button that triggers the following javascript function:</p>
  
  <pre><code>function editOpinion(id) {
      var formDiv = $("#opinionEditForm");
      formDiv.html();
      formDiv.load("/umbraco/surface/OpinionsSurface/editOpinion/" + id, function () {
          $("form").removeData("validator");
          $("form").removeData("unobtrusiveValidation");
          $.validator.unobtrusive.parse("form");
          bootstrapValidatorFix();
          formDiv.dialog({
              modal: true,
              width: 830,
              height: 800,
              title: "Edit Ethics Opinion",
              resizable: false
          });
      });
  }
  </code></pre>
  
  <p>That function hits a SurfaceController:</p>
  
  <pre><code>    // GET: OpinionsSusrface/editOpinion/5
      [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
      public ActionResult editOpinion(int id)
      {
          Table&lt;Opinion&gt; opinions = db.GetTable&lt;Opinion&gt;();
  
          var opinion = (from o in opinions
                        where o.opinionID == id
                        select new { opinionID = o.opinionID, opinionNumber = o.opinionNumber, title = o.title, opinionDate = o.opinionDate, summary = o.summary, bodyText = o.bodyText }).FirstOrDefault();
  
          OpinionViewModel ovm = new OpinionViewModel();
          ovm.opinionID = opinion.opinionID;
          ovm.opinionNumber = opinion.opinionNumber;
          ovm.title = opinion.title;
          ovm.opinionDate = opinion.opinionDate.ToString("MM/yyyy");
          ovm.summary = opinion.summary;
          ovm.bodyText = opinion.bodyText;
  
          ViewBag.Action = "Edit";
          return PartialView("/Views/MacroPartials/Admin/Ethics/_OpinionEdit.cshtml", ovm);
      }
  </code></pre>
  
  <p>which creates an edit form and the previous javascript injects that form into the afore mentioned div and displays that div as a modal dialog. I can make changes to the form, hit save, the form posts back to the following controller:</p>
  
  <pre><code>    // POST: OpinionsSurface/Edit/5
      [HttpPost]
      [NotChildAction]
      [ValidateAntiForgeryToken]
      [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
      public ActionResult editOpinion(OpinionViewModel model)
      {
          if (!ModelState.IsValid)
          {
              return CurrentUmbracoPage();
          }
  
          Table&lt;Opinion&gt; opinions = db.GetTable&lt;Opinion&gt;();
  
          Opinion opinion = opinions.Where(u =&gt; u.opinionID == model.opinionID).SingleOrDefault();
  
              opinion.opinionNumber = model.opinionNumber;
              opinion.title = model.title;
              opinion.summary = HttpUtility.HtmlDecode(model.summary);
              opinion.bodyText = HttpUtility.HtmlDecode(model.bodyText);
              opinion.opinionDate = DateTime.Parse(model.opinionDate);
              opinion.link = model.opinionNumber + ".pdf";
  
          try
          {
          db.SubmitChanges();
          }
          catch (Exception ex)
          {
          }
          TempData["CustomMessage"] = "Your form was successfully submitted at " + DateTime.Now;
          return RedirectToUmbracoPage(2097);
      }
  </code></pre>
  
  <p>and the record is updated, the page refreshes and my jQuery grid shows the updated values.</p>
  
  <p>What never happens is the success message, passed into TempData is never displayed on the first partial view.</p>
  
  <p>What appears to be an odd side effect, if I put </p>
  
  <pre><code>&lt;p&gt;&lt;span style="color: red;"&gt;@TempData["CustomMessage"]&lt;/span&gt;&lt;/p&gt;
  </code></pre>
  
  <p>on the partial view the form is in, I get the TempData displayed the next time I click to edit a record!  This proves to me that TempData still has my value, waiting to be used.  So why will it only display on the partialview that is a child of my main partialview?  Why won't it display in any location outside of the lowest nested partialview?</p>