Or, depending on what you're trying to do you might not even need to register custom routes at all and a SurfaceController or RenderMvcController in your assembly is all you need.
is the controller a umbraco type controller? So SurfaceController or RenderMvcController?
Think if you are using a SurfaceController you also have to use an additional interface. Don't remember the name right now.
If you are using normal mvc stuff it could be that you have to tell umbraco to not try to map the url to content by adding it to the umbracoReservedUrls app setting.
I'm trying to follow MVC protocol to implement a custom controller, which has both custom model and partial view. My end goal is to make use of the partial view in multiple Umbraco template views.
The controller has an action method to return a list of published content, i would like to make use of this action method in more then one template via:
@{Html.Render action("Action","Controller")}
This works when i make the controller inherit from SurfaceController:
public class MyController : SurfaceController
{
// GET:
public ActionResult MyAction()
{
var rl = new MyModel(CurrentPage);
rl.rootList = Umbraco.TypedContentAtRoot().First().Children;
return PartialView("MyModel", rl);
}
}
When i inherit from RenderMvcController
public class MyController : RenderMvcController
{
// GET:
public ActionResult MyAction(RenderModel model)
{
var rl = new MyModel(model.Content);
rl.rootList = Umbraco.TypedContentAtRoot().First().Children;
return PartialView("MyView", rl);
}
}
Custom route
Hi Umbarco Team Trying to create a custom route to make use of a custom controller and Action method.
I have created the following class :
But i still get no route in route table ? Am i going about this the wrong way ?
thanks Dibs
Hi, try using
RouteTable.Routes.MapUmbracoRoute
Or, depending on what you're trying to do you might not even need to register custom routes at all and a
SurfaceController
orRenderMvcController
in your assembly is all you need.Take a look at the documentation here: https://our.umbraco.org/Documentation/Reference/Routing/
Hi Dibs,
is the controller a umbraco type controller? So SurfaceController or RenderMvcController?
Think if you are using a SurfaceController you also have to use an additional interface. Don't remember the name right now.
If you are using normal mvc stuff it could be that you have to tell umbraco to not try to map the url to content by adding it to the umbracoReservedUrls app setting.
Regards David
Hi David/Gary
I'm trying to follow MVC protocol to implement a custom controller, which has both custom model and partial view. My end goal is to make use of the partial view in multiple Umbraco template views.
The controller has an action method to return a list of published content, i would like to make use of this action method in more then one template via:
This works when i make the controller inherit from SurfaceController:
When i inherit from RenderMvcController
I get the no route error BSOD message
Dibs
RenderMvcController needs a documenttype and a contentnode. You have to name the controller [documenttypealias]controller and than it will work.
is working on a reply...