November Happy Hour will be moved to Thursday December 5th.

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

Vote:
 

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,

Daniel

 

 

#65191
Jan 22, 2013 22:59
Vote:
 

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
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.