9

Situation

We have a Sitecore 8.1 Initial install with a site that has enforceVersionPresence="true" in the site definition. We have a _BasePage template for which in the advanced section we have now enabled enforceVersionPresence. All page templates inherit from this template including the "Home" item of the site.

Sitedefinition added on request:

<site name="MySite_BE"
              enableTracking="true"
              language="nl-BE"
              virtualFolder="/be"
              physicalFolder="/be"
              rootPath="/sitecore/content/MySite/BE"
              startItem="/Home"
              database="web"
              domain="MySiteDomain"
              allowDebug="true"
              cacheHtml="false"
              htmlCacheSize="50MB"
              registryCacheSize="0"
              viewStateCacheSize="0"
              xslCacheSize="25MB"
              filteredItemsCacheSize="10MB"
              enablePreview="true"
              enableWebEdit="true"
              enableDebugger="true"
              disableClientData="false"
              cacheRenderingParameters="true"
              renderingParametersCacheSize="10MB"
              itemwebapi.mode="Off"
              itemwebapi.access="ReadOnly"
              itemwebapi.allowanonymousaccess="false"
              enableItemLanguageFallback="false"
              enableFieldLanguageFallback="false"
              enforceVersionPresence="true"
              dictionaryDomain="MySite BE Dictionary"
              loginPage="/be/login"
              logoutPage="/be/logout"
              scheme="https"
              brandingSettingsPath="/Configuration/Theme Settings"
              principleClaimsInfoClass="MySite.Login.Models.PrincipalClaimsInformation,MySite"
              formsRoot="/sitecore/content/MySite/BE/Reference Content/Forms"
              linkProvider="provider-portal"
              cookieNotice="cookie_hidden"
              patch:before="*[@name='website']"/>

Additional information: We have a custom language stripper to correctly strip the language from the altered URL seeking the language in the secondary segment instead of the primary segment.

Behaviour

When accessing the site on its main domain with a specified language (ea https://mysite.com/be/nl-be) I get a 404 response (LayoutNotFound) but when accessing it though https://mysite.com/be/nl-be/home it works

Observations

When attaching an ItemResolver and stepping through the resolve process it appears that when Sitecore tries to resolve the correct path there is no response (Sitecore.Context.Database.Items[path] where path is /sitecore/content/MySite/BE/Home) this causes other code to be used later in the process which will eventually pick up /sitecore/content/MySite/BE instead of the Home item causing the LayoutNotFound 404 due to the obvious reason this item does not have a layout (as it's the wrong item). The reason appending /home works is because this will cause said code to also return null and push the ItemResolver into using the ResolveUsingDisplayName method which somehow does manage to locate the correct item.

During resolution the following are correct: Context.Site, Context.Language and args.Url.ItemPath

Question

How to configure Sitecore correctly so the enforceVersionPresence does not make the ItemResolver fail?

  • Could you please add to your question how your website under <sites> node is configured in sitecore.config or your patch config? Something like this - <site name="website" enableTracking="true" virtualFolder="/" physicalFolder="/" startItem="/Home" rootPath="/sitecore/content" language="en" database="web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="50MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="25MB" filteredItemsCacheSize="10MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" ... /> – Peter Procházka Mar 20 '18 at 13:45
  • I think you are missing this startItem="/Home" and instead you have this startItem="/". You are effectively navigating to /sitecore/content but that item doesn't have layout specified and that's why you are getting that error but everything is fine for /Home urls – Peter Procházka Mar 20 '18 at 13:46
  • I added the site definition, as you can see this is not the case. Everything works fine when enforceVersionPresence is not active – IvanL Mar 20 '18 at 13:58
  • Can you check whether you are hitting MySite_BE website and not the default website in Item resolver? I have feeling that this is causing you trouble. – Peter Procházka Mar 20 '18 at 14:52
  • @chorpo I can tell you that the Context Site is correct – IvanL Mar 20 '18 at 20:27
0

I assume this issue is related to Sitecore trying to resolve "be" as language code, since its the first part of the url. I think Sitecore doesn't consider "nl-be" as language code since its the second part of the url (hostname/be/nl-be)

In senarios I have used virtualFolder/physicalFolder settings, we have to disable following setting to mention to Sitecore not to look for language code in the first part of the url.

Language.AlwaysStripLanguage to false

So, when using this way, you will have to add 'nl-be' (i.e. in case you need to have that language code also as part of the url) also into your site definition's virtualFolder/physicalFolder settings like below

virtualFolder="/be/nl-be" physicalFolder="/be/nl-be"

| improve this answer | |
  • I'm sorry but this is not the case. We have a custom language stripper that removes the secondary part of the URL instead of the primary part. As mentioned before, the Context Site, Language and Path are correct, they simply do not resolve properly. – IvanL Mar 22 '18 at 9:07
-1

Please add the same flag of enforceVersionPresence=true to website site tag as well which is also required.

Reference:https://kb.sitecore.net/articles/350702

| improve this answer | |
  • They have it like that. Take a look on site definition in Question – Peter Procházka Mar 20 '18 at 14:42
  • The added site definition is the new one. As per reference link , you should add the same flag in default website site node as well that is where site node [@name='website'].. – Vinayak Chauhan Mar 20 '18 at 14:47
  • @VinayakChauhan I'm affraid you're reading the documentation incorrectly. It clearly states Enable Enforce Version Presence on the desired sites(*) in Sitecore configuration(**). Key word here is desired which would imply only the site I've posted in this question. Aside from that it isn't that enforceVersionPresence isn't working, it's simply not operating accordingly when doing Item Resolution through a path. The context language and website are both correct, the path is correct, it simply yields null which implies that path resolution was affected by activating the feature – IvanL Mar 20 '18 at 20:26
  • @IvanL, You are correct. Website tag will not required that flag to be true. it will be required only there is one site. I have done one test with sample Item, that if i will check the checkbox of "Enforce Version Presence" on template standard value, its not working but if i will enable this flag on Item level, its working for me. – Vinayak Chauhan Mar 21 '18 at 5:24
  • Note: Also i have access the URL like sample82/en/home which is default and sample82/ar-AE/home which is not having any version and so redirecting me to default notfound page of sitecore. Can you test the same on item level if its working for you or not? – Vinayak Chauhan Mar 21 '18 at 5:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.