More in this section

Forums / Developing with Sitefinity / UrlWithExtension issue

UrlWithExtension issue

3 posts, 0 answered
  1. Scott Rozman
    Scott Rozman avatar
    93 posts
    Registered:
    10 Oct 2012
    06 Jul 2010
    Link to this post
    I am trying to use the UrlWithExtension Property of IContent to retrieve URLs of my events.
    I happen to have some events that were published on the same day and have the same title.... they are monthly meetings that I entered all at the same time.
    Using UrlWithExtension I am getting the URL of the first one entered every time.
    /10-02-09/CASI_meeting.aspx
    However when I create an RSS feed in Sitefinity, I get different URLs for each, so it seems there is a way to deal with this... for example:
    10-02-09/CASI_meeting-536063314.aspx

    How can I retrieve a UrlWithExtension that is guaranteed to be unique?

    Also, I notice that UrlWithExtension is not documented in the 3.7 Developer Manual. I found it through someone else's code... don't remember where....and see it with intellisense.

    thanks in advance!
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    07 Jul 2010
    Link to this post
    Hello Scott Rozman,

    It depends on how( in the context of) you are trying to get the UrlWithExtension property. Generally the Title is not unique identifier for an IContent object and you should better use the ID of this item

    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
  3. Scott Rozman
    Scott Rozman avatar
    93 posts
    Registered:
    10 Oct 2012
    07 Jul 2010
    Link to this post
    Due to the need for additional filtering on my RSS feeds I made a handler to output events matching certain metadata. For whatever reason, items with the same title published on the same day were not returning the correct UrlWithExtension. I have since tried just returning the Url and adding ".aspx" myself. That is working, so I guess I don't need further help, but would be curious if was using UrlWithExtension in some way that would not work as I was expecting. If I look at my event content in sf_CmsContentBase, the Urls are unique.

    Here is the relevant snippet of code I was working with:
    IList listOfEventsItems = eventsManager.Content.GetContent("Event_Start DESC", filter.ToArray());
     
            if (listOfEventsItems.Count > 0)
            {
                foreach (Telerik.Cms.Engine.IContent eventsItem in listOfEventsItems)
                {
                    rssFromEventsItems = (rssFromEventsItems + "<item>\n");
                    rssFromEventsItems = (rssFromEventsItems + "<title>" + "<![CDATA[" + eventsItem.GetMetaData("Title") + "]]>" + "</title>\n");
                    string eventURL = "";
                    if (filterOutlet != null)
                    {
                        eventURL = "http://" + context.Request.Url.Host + "/" + filterOutlet + "/Event" + eventsItem.UrlWithExtension;
                    }
                    rssFromEventsItems = (rssFromEventsItems + "<link>" + eventURL + "</link>\n");
Register for webinar
3 posts, 0 answered