Error Cannot implicitly convert type 'Umbraco.Core.Dynamics.DynamicNull' to '...' when render partial
Hi,
I have issue with rendering of a partial view Header.
I have a controller which is incherited from SurfaceController.
// GET: Header
public ActionResult Index()
{
var content = Umbraco.Content(1054);
Header viewModel = content.MapTo<Header>();
return PartialView("Header", viewModel);
}
When I try to MapTo it gives me an error Cannot implicitly convert type 'Umbraco.Core.Dynamics.DynamicNull' to 'FormsWorkflow.UmbracoPortal.Models.Pages.Header'. Content contains properties list with my component.
Can you please help..What is wrong?
Error Cannot implicitly convert type 'Umbraco.Core.Dynamics.DynamicNull' to '...' when render partial
Hi, I have issue with rendering of a partial view Header. I have a controller which is incherited from SurfaceController.
When I try to MapTo it gives me an error Cannot implicitly convert type 'Umbraco.Core.Dynamics.DynamicNull' to 'FormsWorkflow.UmbracoPortal.Models.Pages.Header'. Content contains properties list with my component. Can you please help..What is wrong?
Hi Karie
What is 'Header' type in your code?
Umbraco.Content(1054) returns dynamics, it's definitely can't be a 'Header', so this code is wrong
Thanks,
Alex
Thanks, ok) What is the alternative?
Hi Karie
Use TypedContent, have a look - https://our.umbraco.org/documentation/reference/querying/umbracohelper/#typedcontent-int-id
/Alex
is working on a reply...