Opticon Stockholm is on Tuesday September 10th, hope to see you there!
Opticon Stockholm is on Tuesday September 10th, hope to see you there!
Hmm, sounds strange. That sounds like the resolving of SiteDefinition.Current for some reason returns wrong site. As the algioritm works it will look at Authority part of HttpRequestBase.Url and match that value against the hosts for the different sites.
Could it be that there is some proxy or similar that does some rewrite/redirect? But then on the other hand that would not explain that it is only the start page that gets wrong site... But that would explain why you would get the main site, since all unknown hosts will be using the wildcard site.
Do you have any logs where wou can see the request url as it appears to the application? Just to verify that it is no rewrite going on.
How do you resolve mainsite.com and newsite.com?
We had a similar issue with a reverse proxy, it turned out that the RP caching flipped when having multiple hostnames on the same application. We had to separate the sites in the cache adding the correct headers based on the current site, I cannot really remember what it was but some proxy_pass or similar.
We detected the issue by adding log events to the start page detecting the additional sites never got any hits when the main site had been cached by the RP. This could also be the reason your subpages works just fine but if you have the same address to a page on the main and new site you will probably get the page served first
i.e. mainsite.com/about and newsite.com/about, if main is loaded first you'll get that page also when trying to load the newsite.com/about page.
Seems to be episerver applicationsettings httpCacheVaryByCustom and httpCacheVaryExpiration
When i change httpCacheVaryByCustom from "path" to "host" it works
BUT it only caches the mainsite.com, not newsite.com
Im printing @DateTime.Now.Ticks to be able to found out this...
How come httpCacheVaryExpiration only works on mainsite?
</body> </html>May be this is useful to someone in future. We had the same exact problem with episerver 11.10. The site was hosted with Episerver DXC with 10 multisites. The random start website page shows up however url stays intact. The underlying pages work fine.
Adding httpCacheVaryByCustom="host" solved nothing <applicationSettings httpCacheVaryByCustom="host" />
As a workaround, I had to remove caching from start page types for varying host names:
public class StartPageController : BasePageController<StartPage>
{
[OutputCache(VaryByCustom = "Host", Duration = 120)]
// OR [OutputCache(Location = OutputCacheLocation.None, NoStore = true )] // depending on your need
public override ActionResult Index(StartPage currentPage)
{
var model = new PageViewModel<StartPage>(currentPage);
return View(model);
}
}
And in Global.asax.cs
public override string GetVaryByCustomString(HttpContext context, string arg)
{
if (arg.Equals("Host"))
{
return context.Request.Url.Host;
}
return base.GetVaryByCustomString(context, arg);
}
Totally forgot to write an answer to this. I marked yours as an answer.
Turned out that one of my Startpage MVC controller was using
[OutputCache(Duration = 120)]
And the other did not use outputcache, so i removed all outputcache and it worked for me.
Cms version 10.10.4 (on prem)
So i have this stange behavior, both in production and staging. NOT in dev.
We newly added a site to a one site setup. We are runing it on the same IIS app-pool and website. Different binding are applied. Setup in admin/websites where main site has a *.
www.mainsite.com - working
www.newsite.com - is at startup working fine, then after a short while, returns the content of the mainsite under the new domain.
www.newsite.com/?whatever returns the new site always = good
www.newsite.com/anypage/ returns the page on new site
So it is only the root returning wrong content
It is not the local cache.
So im thinking is something on the network? fooling episerver? we are using "netscaler"-product, we are using SSL, we are using 301 redirects to SSL.
What can it be? any hints appreciated
Regards
Note: As a workaround, i had to run the sites in different IIS websites/app-pools. Then it works.