title: MVC Surface Controller & Umbraco Current Node
body: <p>I'm trying to write a childaction function in a surface controller that gets called by a macro to render a PartialView.</p>
  
  <p>I need in this function to gain access to my current page properties to then tweak the rendered PartialView with.</p>
  
  <p>I got this from Jorge Lusar's code on ubootstrap and it works fine on the HttpPost ActionResult function :</p>
  
  <pre><code>var renderModel = (UmbracoRenderModel)ControllerContext.RouteData.DataTokens["umbraco"];
  var currentPage = renderModel.CurrentNode.AsDynamic();
  </code></pre>
  
  <p>Problem is I've this error thrown on <strong>[ChildActionOnly] PartialViewResult</strong> function :</p>
  
  <pre><code>Unable to cast object of type 'System.String' to type 'Umbraco.Cms.Web.Model.UmbracoRenderModel'.
  on 'var renderModel = (UmbracoRenderModel)ControllerContext.RouteData.DataTokens["umbraco"];'
  </code></pre>
  
  <p>Data in DataTokens["umbraco"] seems to change between the two functions.
  If I diplay <strong>DataTokens["umbraco"].ToString()</strong> on each one, here is what happens:</p>
  
  <p>On <strong>[ChildActionOnly] public PartialViewResult Init() -> "Surface"</strong> is displayed.</p>
  
  <p>On <strong>[HttpPort] public HandleSubmit(myModel model) -> "Umbraco.Cms.Web.Model.UmbracoRenderModel"</strong> is displayed.</p>
  
  <p>Thanks for any advice here.</p>
  
  <p>Nicolas.</p>