Let's assume that your doctype has alias of "noTemplate"
What you would do then is create a controller that inherits from RenderMvcController and is named as following : doctypealias + Controller. In this case that would be NoTemplateController
public class NoTemplateController : Umbraco.Web.Mvc.RenderMvcController
{
public override ActionResult Index(RenderModel model)
{
//Do some stuff here, then return the base method
return this.View("NoTemplateViewPath", model: model);
}
}
In the index method you will set the correct view that you want to render.
MVC Routing or SurfaceRouting Question (newbie)
Anyone have any idea how to automatically add a route for a document type that has no template to a surface controller?
I'd settle for an attribute or code; I just cannot seem to quite understand how this is wired together.
Hi John,
Surface controllers are auto-routed, so you can not assign a route to it. I even think if you try to that you will break your site.
See the docs of surface controllers to know more about them : https://our.umbraco.org/documentation/Reference/Routing/surface-controllers
What you are looking for is "Route Hijacking". See the docs for route hijacking : https://our.umbraco.org/documentation/Reference/Routing/custom-controllers
Let's assume that your doctype has alias of "noTemplate"
What you would do then is create a controller that inherits from RenderMvcController and is named as following : doctypealias + Controller. In this case that would be NoTemplateController
In the index method you will set the correct view that you want to render.
Dave
is working on a reply...