0
votes

I have this problem. I created the "Topic" action with the parameter "topic" but when I go to "About / Topic? topic = aloha" I can not find this action and I get an error: "Page not found No umbraco document matches the url '/ About / Topic? Topic = aloha'. "

Controller:

public class AboutController : Umbraco.Web.Mvc.RenderMvcController
{
    // GET: About
    public ActionResult About(RenderModel model)
    {
        return View("About", model);
    }

    public ActionResult Topic( string topic)
    {
        return View("About");
    }
}

Routing:

public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
        routes.MapRoute(
        name: "Default1",
        url: "{controller}/{action}/{topic}",
        defaults: new { controller = "About", action = "Topic", topic = UrlParameter.Optional }
        );
    }
1

1 Answers

0
votes

If you are using an Umbraco Mvc controller you'll have to create your routes in the Umbraco pipeline and not in the regular MVC routing.

From the docs:

You can specify your own custom MVC routes to work within the Umbraco pipeline. This requires you to use an implementation of Umbraco.Web.Mvc.UmbracoVirtualNodeRouteHandler with your custom route.

For Umbraco V7 more info here

For Umbraco V8 more info here