+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / How do I construct a dynamic page url in Sitefinity?

How do I construct a dynamic page url in Sitefinity?

4 posts, 1 answered
  1. Dan Sorensen
    Dan Sorensen avatar
    256 posts
    Registered:
    13 Aug 2010
    18 Feb 2011
    Link to this post
    We have a main landing page:

    www.ourwebsite.com/home/

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

    www.ourwebsite.com/home/wa/
    www.ourwebsite.com/home/ca/
    www.ourwebsite.com/home/or/
    www.ourwebsite.com/home/nv/

    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!
    Thanks,
    Dan
  2. Bob
    Bob avatar
    330 posts
    Registered:
    24 Sep 2012
    03 Mar 2011
    Link to this post
    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: http://www.sitefinity.com/documentation/how-to-create-a-widget/creating-a-widget-as-a-user-control/register-the-widget-in-sitefinity.aspx

    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,
    Bob
    the Telerik team
    Answered
  3. Anju
    Anju avatar
    19 posts
    Registered:
    22 Jul 2014
    16 May 2015
    Link to this post

    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. 

    Thanks,

    Anju

  4. Dave
    Dave avatar
    2 posts
    Registered:
    01 Oct 2012
    16 May 2015 in reply to Anju
    Link to this post

    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.

4 posts, 1 answered