I have implemented route hijacking by using
@inherits UmbracoViewPage[MyModel] in the view and MyModel inherits from RenderModel, everything works fine.
In my controller I have
public override ActionResult Index(RenderModel rm)
{
var myModel = new MyModel(rm.Content, rm.CurrentCulture);
...
return CurrentTemplate(myModel);
}
My question is: How do I take another parameter in my Index-method?
I have tested having another method like
public ActionResult MyIndex(RenderModel rm, int customerId)
{
//same as above
}
(since I have seen such solutions on forums) , but I cant call it from my browser by instead of going to
http://... /mycustomerpage/myindex?customerId=23
Is this just a routing problem or how do I send extra parameters?
I'm guessing that "MyIndex" isn't a template defined on the related document type?
Actions inside a RenderMvcController map to that specific document type's templates.
Index is called for all templates.
So I would rename "MyIndex" to your template's name.
You don't have to mention this part in the url.
Or provide more clarity about the related document type & available templates.
...
with this (an old question from me here on this forum)
I guess that you can have one controller for the document type and then a method for each page template. (I havent thought about what that actually means or if its smart to do so... but I guess you could)
Depends on what you need to implement.
Most of the time we usually only have 1 template / document type so it doesn't really make a difference.
Index can be used for shared logic across all templates,
Template specific action is also logic specific for that template.
Extra parameters when using route hijacking
I have implemented route hijacking by using @inherits UmbracoViewPage[MyModel] in the view and MyModel inherits from RenderModel, everything works fine.
In my controller I have
My question is: How do I take another parameter in my Index-method?
I have tested having another method like
(since I have seen such solutions on forums) , but I cant call it from my browser by instead of going to
http://... /mycustomerpage/myindex?customerId=23
Is this just a routing problem or how do I send extra parameters?
I'm guessing that "MyIndex" isn't a template defined on the related document type? Actions inside a RenderMvcController map to that specific document type's templates. Index is called for all templates.
So I would rename "MyIndex" to your template's name. You don't have to mention this part in the url. Or provide more clarity about the related document type & available templates.
Holy kows! Thanks :D
Renaming my Index2 to the name of the template helped. Thanks alot!
I must admid I was kind of clueless about that RenderMvcController mapped to a specific template.
In in this example I had 1 DT and 1 Page Template
... with this (an old question from me here on this forum) I guess that you can have one controller for the document type and then a method for each page template. (I havent thought about what that actually means or if its smart to do so... but I guess you could)
Depends on what you need to implement. Most of the time we usually only have 1 template / document type so it doesn't really make a difference. Index can be used for shared logic across all templates, Template specific action is also logic specific for that template.
is working on a reply...