How do I construct a dynamic page url in Sitefinity? - General Discussions - General Discussions - Progress Community
 General Discussions

How do I construct a dynamic page url in Sitefinity?

  • How do I construct a dynamic page url in Sitefinity?
  • We have a main landing page:

    And from there, we have different pages for each customer category, in our case by state.

    Each of those customer category pages are exactly the same, except that they pull data from the database for their category/region based on the url string. Washington customers get a washington version of their page because of the /wa/ in the address. Therefore they can bookmark their territory page.

    My question: can this be done in Sitefinity? Is there any way to build a page that uses a url param to load data for a common template? All widgets on the page should load data filtered by that same url param.

    I know how to build the widgets that will filter the data based on that url param, but I'm not sure how to get a base page in Sitefinity with different urls like that.

    Any hints, help or direction helps!
  • Hi Dan,

    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, no matter what you place after ~/home, the home page will be loaded and you can access the rest in the URL as parameters.

    To test this, do the following test:

    1.       Create a user control, let’s say MyControl.ascx in the root of the site.

    2.       Add a Label to the User Control.

    3.       Add the following code in the code behind file:


    public partial class MyControl : System.Web.UI.UserControl
        protected void Page_Load(object sender, EventArgs e)
            this.Label1.Text = String.Empty;
            var parms = (string[])this.Request.RequestContext.RouteData.Values["Params"];
            if (parms != null)
                foreach (var param in parms)
                    this.Label1.Text += param + "</br>";



    4.       Add the user control to the Page Toolbox. See this instructions how to add user control to the toolbox:

    5.       Drop that control to your home page

    NOTE: this behavior is subject to change in the near future because a lot of people perceive it as bug, since we don’t throw HTTP 404 exception. Nevertheless the current behavior will also be supported (configurable) and you also will be able to specify matching patterns.

    I hope this answers your question. Let me know you need further clarification.  

    Kind regards,
    the Telerik team
  • Hi,

    This was what i was exactly looking for. But its still giving me the same error  :

     HTTP Error 404.0 - Not Found
    The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

     Is dynamic url possible in sitefinity. What is going wrong. I have been trying long for this. Even though i have added the code mentioned above, my user control is not getting triggered. Its throwing the error mentioned above.

    Please help. 



  • You need to tell Sitefinity you are handling the dynamic URL otherwise it will throw a 404 (from 7.2 upwards)

     Just use RouteHelper.SetUrlParametersResolved(); somewhere in your widget and it won't 404.