Hi Guys,
If you’ve ever tried to get the full URL of a current page then this blog post may come handy. So basically you will need VirtualPathArguments, That will have ContextMode facility to enable it based on our needs. For instance Default mode, Edit mode, Preview mode and obviously an Undefined mode if the Context has not been defined.
And then obviously the “Uri” method with the “SiteDefinition.Current.SiteUrl”.
This is a small blog post that covers the absolute/full URL of the current page on any block or on a page.
var routeHelper = ServiceLocator.Current.GetInstance();
var pageUrl = UrlResolver.Current.GetUrl(routeHelper.Page.ContentLink,
ContentLanguage.PreferredCulture.Name,
new VirtualPathArguments { ContextMode = EPiServer.Web.ContextMode.Default });
var absoluteurl = new Uri(SiteDefinition.Current.SiteUrl, pageUrl);
Thanks for reading this blog post I hope it helps
Thanks and regards
Ravindra S. Rathore