Getting the absolute URL of the hostname or the root URL
I have a site with a few subdomains on it that use all use the same navigation and footer (via partial macros)
Content tree
- www.mainsite.com
- subdomain1.mainsite.com
- subdomain2.mainsite.com
Is there a way to pull in the absolute URL of the "www.mainsite.com" without actually typing that in to all of the href's for the nav and footer? I assumed there would be an easy way to do this, and I have tried a few solutions - but none have worked.
After experiencing a similar problem and coming across your question, I have found a solution.
In order to pull the current absolute URL you can create a string template which would dynamically render the absolute URL depending on the current path.
Getting the absolute URL of the hostname or the root URL
I have a site with a few subdomains on it that use all use the same navigation and footer (via partial macros)
Content tree
- www.mainsite.com
- subdomain1.mainsite.com
- subdomain2.mainsite.com
Is there a way to pull in the absolute URL of the "www.mainsite.com" without actually typing that in to all of the href's for the nav and footer? I assumed there would be an easy way to do this, and I have tried a few solutions - but none have worked.
Here is what HASN'T worked so far:
@Request.Url.ToString()
@Request.RawUrl.ToString()
@Request.UserHostName
@Request.Url.AbsoluteUri
@Request.Url.AbsolutePath
@Request.Url.Host
@Request.Url.Scheme
@Request.Url.Authority
@Request.Url.AbsolutePath
Any idea what the issue might be?
Hi Mike!
After experiencing a similar problem and coming across your question, I have found a solution.
In order to pull the current absolute URL you can create a string template which would dynamically render the absolute URL depending on the current path.
Then pass the variable to where you wish to use the absolute URL.
Hope it helps!
is working on a reply...