Today i wanted to do something that would seem simple, and should be simple, but was not. The problem:
Using a combination of PortalSettings.HomeDirectory which returns /Portals/portaldirectoryname/, and DotNetNuke.Common.Globals.GetDomainName which in most cases returns
www.domain.com,
www.domain.com/vdir, or localhost/vdir etc.
I was attempting to get a full url to pass as a item in a playlist to media player, to a specific file within the portal. It seems simple , but i always ended up with domain/vdir/vdir/portals/homedir, notice how there are duplicate vdirs
now, i assume this would not be a problem if i were just using a straight forward domain name instead of a virtual directory on localhost, but i want this to be bulletproof, even for testing and debugging locally.
So here is the right way to do it:
think of the formula as Globals.GetDomainName - Globals.ApplicationPath + PortalSettings.HomeDirectory = good url
Dim strDomain AsString = DotNetNuke.Common.GetDomainName(HttpContext.Current.Request)strDomain = DotNetNuke.Common.AddHTTP(strDomain)
strDomain = Replace(strDomain, DotNetNuke.Common.Globals.ApplicationPath, "")
and after doing that, you have the root string for the domain, which can be joined to the homedirectory string, like this:
dim goodString as string = strDomain & PortalSettings.HomeDirectory
One more problem solved