Routing, first umbraco, then to custom controllers
I've created my own controller like this:
public class TestController : Umbraco.Web.Mvc.SurfaceController
{
[Route("{categoryAlias}/{productAlias}")]
public ActionResult Index(string categoryAlias, string productAlias)
{
return Content($"Category: {categoryAlias} - productAlias: {productAlias}");
}
}
And implemented an IComponent like this
public class RegisterCustomRouteComposer : ComponentComposer<RegisterCustomRouteComponent>
{
}
public class RegisterCustomRouteComponent : IComponent
{
public void Initialize()
{
RouteTable.Routes.MapMvcAttributeRoutes();
}
public void Terminate()
{
throw new NotImplementedException();
}
}
This works perfectly because when I call the path /category1/productname1 it'll return
Category: category1 - productAlias: productname1
Problem is that now it'll also choose my custom controller even if I go to /contact/email which is an existing umbraco page.
This means I am hijacking ALL of the calls to anything with 2 levels of nodes (/anything/anything).
Is there a way to make it first check if there is an existing umbraco node/path and if not then to defer to any custom MVC controllers willing to take the request. Now it seems to be the other way around.
Routing, first umbraco, then to custom controllers
I've created my own controller like this:
And implemented an IComponent like this
This works perfectly because when I call the path /category1/productname1 it'll return
Problem is that now it'll also choose my custom controller even if I go to /contact/email which is an existing umbraco page.
This means I am hijacking ALL of the calls to anything with 2 levels of nodes (/anything/anything).
Is there a way to make it first check if there is an existing umbraco node/path and if not then to defer to any custom MVC controllers willing to take the request. Now it seems to be the other way around.
is working on a reply...