The model item passed into the dictionary is of type 'Umbraco.Web.Models.RenderModel', but this dictionary requires a model item of type 'Product'.
Here is my model:
public class Product : RenderModel
{
public Product(IPublishedContent content, CultureInfo culture) : base(content, culture)
{
}
public Product(IPublishedContent content) : base(content)
{
}
public int Id { get; set; }
public string Make { get; set; }
public string Model { get; set; }
public int Year { get; set; }
public string Engine { get; set; }
}
Here is my Controller:
public class ProductController : RenderMvcController
{
public ActionResult Product(RenderModel model)
{
var product = new Product(model.Content, model.CurrentCulture) { Make = "Honda", Model = "Civic" };
return CurrentTemplate(product);
}
}
John, This is really strange. In my back office, I have a Home and Product Document Type. I also have a matching Template for each(Home and Product). If I create a HomeController:
public class HomeController : RenderMvcController
{
public ActionResult Home(RenderModel model)
{
var product = new Product(model.Content, model.CurrentCulture) { Make = "Camry" };
return CurrentTemplate(product);
}
}
Everything works fine, but if I do the same exact code with a ProductController with a Product View, I get the error. The only difference between the Home and Product, is that I called my controller ProductController and I called my ActionResult method Product.
I figured out the problem, but I am not sure why: The Product page had a DocumentType of Landing Page. Landing Page just allows a Text Page template, so I created a Product Doc Type and Template and allowed Product Templates to be created under the root (Home) node. After doing this, my controller action was hit and everything worked.
RenderMvcController error?
I am getting the following error:
The model item passed into the dictionary is of type 'Umbraco.Web.Models.RenderModel', but this dictionary requires a model item of type 'Product'.
Here is my model:
Here is my Controller:
Here is my View:
I got this to work using a SurfaceController, so I am a bit confused on what the point of a RenderMvcController is?
Have you tried adding override to the action result?
public override ActionResult Product (RenderModel model)
John, This is really strange. In my back office, I have a Home and Product Document Type. I also have a matching Template for each(Home and Product). If I create a HomeController:
And then in my View:
Everything works fine, but if I do the same exact code with a ProductController with a Product View, I get the error. The only difference between the Home and Product, is that I called my controller ProductController and I called my ActionResult method Product.
I figured out the problem, but I am not sure why: The Product page had a DocumentType of Landing Page. Landing Page just allows a Text Page template, so I created a Product Doc Type and Template and allowed Product Templates to be created under the root (Home) node. After doing this, my controller action was hit and everything worked.
Dang, this was poised to be the first thread I could actually provide some help with, but you fixed it before I got to it. ;)
-j
Jason, I still don't understand why. I am creating another question.
is working on a reply...