Generic UmbracoViewPage, Custom Models and route hijacking
I am trying to combining the generic version of UmbracoViewPage, custom models and route hijacking but the model returned doesn't contain my bespoke properties. My controller action is
public override ActionResult Index(RenderModel model)
{
var newModel = new RenderNewModel(model.Content);
newModel.test = 'test';
return CurrentTemplate(newModel);
}
When I inherit from UmbracoViewPage in the view the RenderNewModel is available but when I use the generic version the model is RenderModel
The view/template that you are using with your hijacked route and your custom model, needs to inherit:
@inherits UmbracoViewPage<RenderNewModel>
this tells your view about the existence of your custom model, and so makes your custom properties available; since your custom model inherits from RenderModel, then it also has all the usual model properties available... eg .Name, .Id etc
The UmbracoViewPage bit ensures you have access to all those nice @Umbraco helpers within your view...
Generic UmbracoViewPage, Custom Models and route hijacking
I am trying to combining the generic version of UmbracoViewPage, custom models and route hijacking but the model returned doesn't contain my bespoke properties. My controller action is
When I inherit from UmbracoViewPage in the view the RenderNewModel is available but when I use the generic version the model is RenderModel
How can I can make this work?
Hi Phil
The view/template that you are using with your hijacked route and your custom model, needs to inherit:
this tells your view about the existence of your custom model, and so makes your custom properties available; since your custom model inherits from RenderModel, then it also has all the usual model properties available... eg .Name, .Id etc
The UmbracoViewPage bit ensures you have access to all those nice @Umbraco helpers within your view...
is working on a reply...