Try Now
More in this section

Forums / General Discussions / Sitefinity url routing question

Sitefinity url routing question

2 posts, 0 answered
  1. minco
    minco avatar
    20 posts
    16 Jun 2014
    21 Jul 2014
    Link to this post

    Hi  everybody, 

    I'm using Sitefinity 6.3 .  I created  a "Test" page in Sitefinity. 

     I want to use a site for Test with a parameter .so the URL would look like this:

    1.) Url: /Test /{model}
      Resolve to: /Test ?m={model}

    I have referred to the web site (http://www.sitefinity.com/developer-network/forums/developing-with-sitefinity-/url-routing) ,  If I input "http://localhost:60876/test"  ,it's OK.  

    But I input "http://localhost:60876/test/minco"  , it will show empty.

    This my sample code .


    protected void Application_Start(object sender, EventArgs e)
               Telerik.Sitefinity.Services.SystemManager.ApplicationStart += new EventHandler<EventArgs>(SystemManager_ApplicationStart);         
           void SystemManager_ApplicationStart(object sender, EventArgs e)

    CustomSitefinityRoute.cs :

    namespace SitefinityWebApp
        public class CustomSitefinityRoute : SitefinityRoute
            public override System.Web.Routing.RouteData GetRouteData(HttpContextBase httpContext)
                //get the path from the httpContext variable and parse it
                var virtuallPath = this.GetVirtualPathInternal(httpContext);
                if (virtuallPath.Contains("test"))
                    //parse the acutal path to find the PageSiteNode from the sitemap provider
                    var sitemapProvider = this.GetSiteMapProvider();
                    if (sitemapProvider == null)
                        return null;
                    bool isAdditional;
                    string[] pars;
                    var node = sitemapProvider.FindSiteMapNode("test", false, out isAdditional, out pars);
                    if (node != null)
                        return this.GetRouteDataInternal(pars, httpContext.Request.QueryString, node);
                return base.GetRouteData(httpContext);
            public static void RegisterType()
                ObjectFactory.Container.RegisterType<SitefinityRoute, CustomSitefinityRoute>();

    Anybody can help me  ? 




  2. Pavel Uzunov
    Pavel Uzunov avatar
    7 posts
    13 Sep 2016
    24 Jul 2014
    Link to this post

    Sitefinity support parameters in the URL, so you can use it for this issue. Sitefinity will load the last valid page in the path of the requested URL and the rest of the URL will be treated as URL parameters. In your example, if you start with ~/test, no matter what you place after it, the test page will be loaded and you can access the rest in the URL as parameters.

    If you have a custom control/widget that relies on this parameters in the URL, you have to add this line of code to indicate that you have processed a specific parameters:


    Moreover, you can get all parameters with this code:

    var params this.Request.RequestContext.RouteData.Values["Params"as string[];
    if (params != null)

    In addition you can take a look at this blog post: 404 and custom Parameters

    Pavel Uzunov
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items

2 posts, 0 answered