I’ve got a clean asp.net mvc website that I would like to move to Umbraco. I thought that it would be easy – just add some routing, inherit from SurfaceController and bam...that’s it.
All views render as expected but I can’t get nodes from Umbraco from my SurfaceController. Can it be because I’m using custom routing?
So here's what I got.
First I added custom routing to Umbraco:
public class StartupHandler : Umbraco.Core.IApplicationEventHandler
{
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
RouteTable.Routes.MapRoute(
"recipe",
"recipe/{action}/{url}",
new
{
controller = "Recipe",
action = "Index",
url = UrlParameter.Optional
});
}
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
}
Then I changed my controllers to inherit from SurfaceController:
public class RecipeController : Umbraco.Web.Mvc.SurfaceController
{
public RecipeController() : this(UmbracoContext.Current)
{
}
public RecipeController(UmbracoContext umbracoContext) : base(umbracoContext)
{
}
}
Even though I got the UmbracoContext I can’t get any nodes. All return null. Any ideas?
Get node from a SurfaceController?
Hi
I’ve got a clean asp.net mvc website that I would like to move to Umbraco. I thought that it would be easy – just add some routing, inherit from SurfaceController and bam...that’s it.
All views render as expected but I can’t get nodes from Umbraco from my SurfaceController. Can it be because I’m using custom routing?
So here's what I got.
First I added custom routing to Umbraco:
Then I changed my controllers to inherit from SurfaceController:
Even though I got the UmbracoContext I can’t get any nodes. All return null. Any ideas?
Umbraco version 7.15
is working on a reply...