Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Josip 195 posts 662 karma points c-trib
    Oct 26, 2019 @ 20:28
    Josip
    0

    Custom route exception

    Hi all,

    I see in Umbraco log viewer a lot of errors like this one:

        System.NotImplementedException: The method or operation is not implemented.
       at project.Code.RegisterCustomRouteComponent.Terminate() in d:\a\1\s\project\Code\SupplierProfileRoute.cs:line 36
       at Umbraco.Core.Composing.ComponentCollection.Terminate() in d:\a\1\s\src\Umbraco.Core\Composing\ComponentCollection.cs:line 47
       at Umbraco.Web.UmbracoApplicationBase.HandleApplicationEnd() in d:\a\1\s\src\Umbraco.Web\UmbracoApplicationBase.cs:line 114
    

    I know that this exception is thrown by this line : throw new NotImplementedException(); I am just not sure if that is normal or I did something wrong.

    This is my custom route code:

    public class SupplierProfileRoute : ComponentComposer<RegisterCustomRouteComponent>
    {
    
    }
    
    public class RegisterCustomRouteComponent : IComponent
    {
        public void Initialize()
        {
            RouteTable.Routes.MapUmbracoRoute("SupplierProfile", "supplier-profile/{id}", new
            {
                controller = "SupplierProfile",
                action = "SupplierProfile",
                id = UrlParameter.Optional
            }, new UmbracoVirtualNodeByIdRouteHandler(1140));
            RouteTable.Routes.MapUmbracoRoute("SupplierProfileEn", "en/supplier-profile/{id}", new
            {
                controller = "SupplierProfile",
                action = "SupplierProfile",
                id = UrlParameter.Optional
            }, new UmbracoVirtualNodeByIdRouteHandler(1140));
        }
    
        public void Terminate()
        {
            throw new NotImplementedException();
        }
    }
    
  • Bo Jacobsen 606 posts 2404 karma points
    Oct 26, 2019 @ 22:19
    Bo Jacobsen
    101

    Hi Josip.

    Just remove throw new NotImplementedException(); and leave the Terminate() method empty if you do not need any logic there.

  • Rasmus Olofsson 23 posts 187 karma points c-trib
    Oct 27, 2019 @ 19:41
    Rasmus Olofsson
    0

    What Bo said. I have a working custom route and my Terminate methoid is empty. I believe Umbraco automatically enters it so since yours throws an exception it will always throw an exception. My method is empty so nothing will happen but it will still enter it.

Please Sign in or register to post replies

Write your reply to:

Draft