How to get the full path of a request within a controller using MVC?


Dear all,

I have multilingual page called "Careers" where the parent is "Home" (startPage) which has 3 children {Job01, Job 02, Job03} and I was wondering how to get the full path? Because I was using the PageData.URLSegment but I can only get the last segment and not the intermediary one.

Thank you very much for your help!

Best regards,




#65191 Jan 22, 2013 22:59
  • Joshua Folkerts
    Member since: 2008

    Are you referring to the friendly url like /home/job1?  I guess alittl more information might help.  Anyway, here is the friendly url from the contentreference.  you can also get the full url in the second codeblock

    var url = new UrlBuilder(data.LinkURL);
                    Global.UrlRewriteProvider.ConvertToExternal(url, data.PageLink, Encoding.UTF8);
                    returnUrl = url.ToString();


    And one from epiboost

    Uri uri = new Uri(EPiServer.Configuration.Settings.Instance.SiteUrl, page.LinkURL);
                UrlBuilder url = new UrlBuilder(uri.AbsoluteUri);
                if (url.QueryCollection["id"] != null && int.Parse(url.QueryCollection["id"]) != page.PageLink.ID)
                    page.PageLink = new PageReference(int.Parse(url.QueryCollection["id"]));
                EPiServer.Global.UrlRewriteProvider.ConvertToExternal(url, page.PageLink, System.Text.UTF8Encoding.UTF8);
                return url.Uri.AbsoluteUri;


    #65196 Jan 23, 2013 5:49