Error when passing a custom model into a Umbraco Partial View
I am trying to create a custom model and pass it to my partial view but I keep getting this error Unable to cast object of type 'Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent' to type 'custom.Model' and cant understand why. I have 3 models, BlogPostModel which inherits from HomeModel which inherits from BaseLayoutModel.
BlogPostModel.cs
public class BlogPostModel : HomeModel
{
public BlogPostModel(RenderModel model) : base(model)
{
}
public IPublishedProperty MainBlogImage { get; set; }
public IPublishedProperty ImageAltText { get; set; }
public IPublishedProperty Introduction { get; set; }
public IPublishedProperty Category { get; set; }
}
HomeModel.cs
public class HomeModel : BaseLayoutModel
{
public HomeModel(RenderModel model) : base(model)
{
}
public IPublishedProperty SiteName { get; set; }
}
BaseLayoutModel.cs
public class BaseLayoutModel : RenderModel
{
public BaseLayoutModel(RenderModel model) : base(model.Content, model.CurrentCulture)
{
}
public IPublishedProperty PageTitle { get; set; }
public IPublishedProperty MainContent { get; set; }
public IPublishedProperty MetaDescription { get; set; }
public IPublishedProperty MetaKeywords { get; set; }
}
My HomeController.cs is
public class HomeController : RenderMvcController
{
public ActionResult Home(RenderModel CurrentItem)
{
var Model = new BlogPostModel(CurrentItem);
//Base Layout Model
Model.PageTitle = CurrentItem.Content.GetProperty("pageTitle");
Model.MainContent = CurrentItem.Content.GetProperty("mainContent");
Model.MetaDescription = CurrentItem.Content.GetProperty("metaDescription");
Model.MetaKeywords = CurrentItem.Content.GetProperty("metaKeywords");
Model.SiteName = CurrentItem.Content.GetProperty("siteName", recurse: true);
return View(Model);
}
}
This is my home page that I want to render partial view on
Error when passing a custom model into a Umbraco Partial View
I am trying to create a custom model and pass it to my partial view but I keep getting this error
Unable to cast object of type 'Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent' to type 'custom.Model'
and cant understand why. I have 3 models, BlogPostModel which inherits from HomeModel which inherits from BaseLayoutModel.BlogPostModel.cs
HomeModel.cs
BaseLayoutModel.cs
My HomeController.cs is
This is my home page that I want to render partial view on
And my partial view is
I cant understand why this isnt working. Please help
is working on a reply...