Problems creating partial router

Vote:
 

Hi

I am trying to create a partial route.

public class TrendPagePartialRouter : IPartialRouter

    {

        public PartialRouteData GetPartialVirtualPath(TlSiteArea content, string language, RouteValueDictionary routeValues, RequestContext requestContext)

        {

            return null;

        }

 

        public object RoutePartial(TlSiteArea content, SegmentContext segmentContext)

        {           

            return content;

        }

    }

 

[InitializableModule]

    [ModuleDependency(typeof(ServiceContainerInitialization))]

    public class RouteConfig : IInitializableModule

    {

        public void Initialize(InitializationEngine context)

        {

            RouteTable.Routes.RegisterPartialRouter(new TrendPagePartialRouter());

        }

        public void Uninitialize(InitializationEngine context)

        {

        }

        public void Preload(string[] parameters)

        {

        }

    }

public class TlSiteAreaController : PageController

    {

        public ActionResult Index(TlSiteArea currentPage)

        {

            return Content("Hej hej " + currentPage.Name);

        }

    }

RoutePartial is called and returns the correct page that is TlSiteArea.

I've tested this on an Alloy website and it worked well but running this code on our client’s solution returns a 404.

#191649
Apr 25, 2018 17:13
Vote:
 

If your partial router handles the segment then it needs to consume it, that is update ReminingPath on the segment context, something like:

   var segmentPair = context.GetNextValue(context.RemainingPath);
            if (<your condition to handle segment>)
            {
                //update remaining path
                context.RemainingPath = segmentPair.Remaining;
                ...morecode
                return yourdata;
            }

            return null;
#191681
Apr 26, 2018 11:59
Vote:
 

Hi Johans, i dont now why i mised it. Thanks for the help :)

#191686
Apr 26, 2018 12:58
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.