We're moving all business logic for a site into MVC controllers to make it testable. So we've added a set of controllers to deal with certain pages on the site with complex functionality.
Using search as an example we'd like to pass additional parameters along with the RenderModel into a hijacked route. Like so:
public ActionResult Index(RenderModel model, int? page) {
However as this won't override the RenderMvcController's index method it causes an error 'Ambiguous match found' as there are two matching actions for Index.
Is there a way of doing this (I could do Request.Querystring["page"] inside the action but that makes it difficult to test) or should I use a different type of controller with a custom route?
Hijack MVC route with additional parameters
We're moving all business logic for a site into MVC controllers to make it testable. So we've added a set of controllers to deal with certain pages on the site with complex functionality.
Using search as an example we'd like to pass additional parameters along with the RenderModel into a hijacked route. Like so:
However as this won't override the RenderMvcController's index method it causes an error 'Ambiguous match found' as there are two matching actions for Index.
Is there a way of doing this (I could do Request.Querystring["page"] inside the action but that makes it difficult to test) or should I use a different type of controller with a custom route?
We ended up using child actions any time custom models were required. http://our.umbraco.org/documentation/Reference/Templating/Mvc/child-actions.
I ran into the same issue and I noticed if you use the template name instead of overriding the Index action it works fine.
public ActionResult Product(RenderModel model, int? productId)
{
...
}
Thanks, Tim.. you saved me a lot of hassle!
is working on a reply...