I'm trying to lock down the best practise when it comes to setting up a custom controller and routes and rendering views that are completely outside of Umbraco and its content.
Basically this part of the application isn't based off any content nodes, or at the very most based off a single "dashboard" node that has subpages that don't need to exist in Umbraco.
The simplest example in the docs[1] would be to use UmbracoVirtualNodeByIdRouteHandler to provide the ID of this 'dashboard' node, but could I use this real node for every single route I'm making?
If that won't work, would I need to create my own implementation of UmbracoVirtualNodeRouteHandler that yields 'fake' IPublishedContent instances per route? I suspect that is what the custom routes docs[2] are saying but I'm unsure without a solid example to look at.
Would appreciate if anyone had any examples or input.
Have you considered setting up a new Area (as in a 'MVC area': right click on your project > Add > Area...) for your custom controllers and views? If they really are outside of the Umbraco context then it should be just plain MVC for you whilst in that area. The routing that gets set up by MVC when you create the area should work without needing to configure anything in Umbraco, as far as I can remember from when I last did this.
Routing to custom controllers
Hi all,
I'm trying to lock down the best practise when it comes to setting up a custom controller and routes and rendering views that are completely outside of Umbraco and its content.
Basically this part of the application isn't based off any content nodes, or at the very most based off a single "dashboard" node that has subpages that don't need to exist in Umbraco.
The simplest example in the docs[1] would be to use
UmbracoVirtualNodeByIdRouteHandler
to provide the ID of this 'dashboard' node, but could I use this real node for every single route I'm making?If that won't work, would I need to create my own implementation of
UmbracoVirtualNodeRouteHandler
that yields 'fake' IPublishedContent instances per route? I suspect that is what the custom routes docs[2] are saying but I'm unsure without a solid example to look at.Would appreciate if anyone had any examples or input.
[1] https://our.umbraco.com/documentation/Implementation/Custom-Routing/#custom-mvc-routes
[2] https://our.umbraco.com/documentation/Reference/Routing/custom-routes#virtual-content
So without testing (yet), it seems something like the accepted answer here is the way to go: https://stackoverflow.com/questions/35647220/how-to-create-a-virtual-node-in-umbraco
This was surprisingly unintuitive without an example to work with, though maybe its just me.
Hi,
Have you considered setting up a new Area (as in a 'MVC area': right click on your project > Add > Area...) for your custom controllers and views? If they really are outside of the Umbraco context then it should be just plain MVC for you whilst in that area. The routing that gets set up by MVC when you create the area should work without needing to configure anything in Umbraco, as far as I can remember from when I last did this.
Lotte
is working on a reply...