I am using Modelsbuilder and all works fine in my views. What i am trying to do is get the strongly typed object in a route hijack. However only way i can see how is
public override ActionResult Index(RenderModel model)
{
var hardwater = new Hardwater(model.Content);
List<Dictionary<string,string>> accordionContent = new List<Dictionary<string, string>>();
What would be the exact CLR type of model.Content in that case? Because the strongly typed models factory is implemented at cache level, it should already be strongly typed.
@Jeroen - no sure he has a "CurrentPage" as this takes place in a hijacked controller. So only RenderModel.Content, which is an IPublishedContent, but should be strongly typed, so it would rather be...
var content = model.Content as Hardwater; if (content == null) throw new Exception("oops?");
Many thanks i went for stephans suggestion works a treat.
I have to say I am loving modelsbuilder, we had talk last week at Manchester meetup all about code first etc, we are trying to get strongly type objects and version control, my personal opinion after trying quite a few things is usync and models builder is a very happy pragmatic solution its easy to use and seems to be performant.
ModelsBuilder in route hijack
I am using Modelsbuilder and all works fine in my views. What i am trying to do is get the strongly typed object in a route hijack. However only way i can see how is
public override ActionResult Index(RenderModel model)
{
var hardwater = new Hardwater(model.Content);
List<Dictionary<string,string>> accordionContent = new List<Dictionary<string, string>>();
//do stuff then pass to view
return base.Index(model);
}
Is this only way of doing it?
Regards
Ismail
What would be the exact CLR type of model.Content in that case? Because the strongly typed models factory is implemented at cache level, it should already be strongly typed.
Hello,
Try this:
Jeroen
@Jeroen - no sure he has a "CurrentPage" as this takes place in a hijacked controller. So only RenderModel.Content, which is an IPublishedContent, but should be strongly typed, so it would rather be...
Both can work :-).
Guys,
Many thanks i went for stephans suggestion works a treat.
I have to say I am loving modelsbuilder, we had talk last week at Manchester meetup all about code first etc, we are trying to get strongly type objects and version control, my personal opinion after trying quite a few things is usync and models builder is a very happy pragmatic solution its easy to use and seems to be performant.
Regards
Ismail
If you want to have some more examples on how the Models Builder can be used with route hijacking check out the Hybrid Framework: http://our.umbraco.org/projects/developer-tools/hybrid-framework-for-umbraco-v7
Jeroen
is working on a reply...