More in this section

Forums / Developing with Sitefinity / Get content based on URL

Get content based on URL

2 posts, 0 answered
  1. higgsy
    higgsy avatar
    336 posts
    05 Aug 2010
    23 Nov 2010
    Link to this post

    I am using the url rewriter to fake a URL. I have two pages like so:

    /local-tn/find-a-local-tn.aspx (this page has a list of all the members)


    /local-tn/find-a-local-tn/member-profile.aspx (this is where the individual member profile is displayed, so if you had clicked on a profile the url would actually be:


    I dont want the /member-profile/ part in the url. I know it is possible to show the listview and singleitemview on the same page, but i dont want to as other parts of the pages are customised. Therefore I have the following rule:


    This works, and then on the user control in member-profile.aspx I am trying to match a content item based on the URL that is being passed in the "title" querystring, like so:

    protected override void CreateContentList() {
        ContentManager oContentMgr = new ContentManager(MembersManager.DefaultContentProvider);
        if (String.IsNullOrEmpty(Context.Request.QueryString["title"])) {
            oRepeater.DataSource = oContentMgr.GetContent();
        else {
            ContentProviderBase oProvider = ContentManager.Providers["membersModule"];
            IContent oContentItem = oProvider.GetContent("/" + Context.Request.QueryString["title"]);
            if (oContentItem != null) {
                itemId = oContentItem.ID;

    But oContentItem is always null. To check I replaced the following line :

    IContent oContentItem = oProvider.GetContent("/" + Context.Request.QueryString["title"]);


    IContent oContentItem = oProvider.GetContent(new Guid("02b7b88b-23bf-4d5d-a3c5-b58837f6a8c0"));

    Which is a valid member profile guid - and wrote out the URLWithExtension. This was exactly the same as the "title" querystring, so why is GetContent(string url) not working for me?

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    23 Nov 2010
    Link to this post
    Hello higgsy,

    There is no overload of ContentManager.GetContent where you can pass the url. You have to create a custom method where you resolve the UrlWithExtension of the IContent and then pass the ID of the item to GetContent method.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered