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

get siteURL from second site

Vote:
 

Hey Guys,

question. (see image). I have 2 sites in my CMS (NL and EN). Both have a starting homepage etc.

Now i have a switch on the site to switch to the other homepage. 

The problem is, from my view i have the contentreference of my (other)homepage then the one i'm on, but when i try @Url.ContentUrl(otherHomepage.ContentLink) i get the first binding of the site. Which can be something different. 

What i want is the SiteURL which i added in the image below. I found a @UriSupport.SiteUrl, but that only gives me the URL of the CurrentSite. I want the URL as in the image from the othersite, then the one i'm one. 

Give the contentReference (of the homepage),how can i retrieve the mainURL?

P.S Using latest EPiServer 8

[Pasting files is not allowed]

#133511
Sep 08, 2015 10:42
Vote:
 

Hi,

Maybe you could explicit pass language branch:

 var url = ServiceLocator.Current.GetInstance<UrlResolver>().GetUrl(ContentReference.StartPage, "nl");
#133663
Sep 08, 2015 12:05
Vote:
 

Hi Grzegorz,

i found the problem... my code was correct, but in my bindings for the site, you can set a primary one. I didnt set that so it randomly (or first) picked one. 

Now i added a primary binding and now @Url.ContentUrl(otherHomepage.ContentLink) picks the correct url..

#133665
Edited, Sep 08, 2015 12:30
Vote:
 

Good to know. I think I made another uglier work around earlier for the same problem :)

#133674
Sep 08, 2015 15:01
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.