I was investigating a failing Selenium test the other day and ran into a bit of trouble. It occured as the EPiServer content database template had been restored and EPiServer was loading the site for the first time after an application pool recycle (For more information on the template database testing environment, please see this article: Keeping reliable test data in EPiServer content database for automated UI tests).
EPiServer Forms’s SetupRootFolderForForm failing when SiteBlockFolder is null
Further investigation using ILSpy led me to a method in the EPiServer.Forms.EditView.InitializationModule called SetupRootFolderForForm.
Part of method SetupRootFolderForForm()
if (flag4) { InitializationModule._logger.Information( "SetupRootFolderForForm: We need to create new folder as root for storing Form's Blocks"); ContentFolder @default = this._contentRepository.Service.GetDefault<ContentFolder>(ContentReference.SiteBlockFolder); @default.Name = InitializationModule._formConfig.Service.RootFolderName; this._contentRepository.Service.Save(@default, SaveAction.Publish, AccessLevel.NoAccess); InitializationModule._formConfig.Service.RootFolder = @default.ContentLink.ToReferenceWithoutVersion(); }
The exception was thrown because the ContentReference.SiteBlockFolder (line 4) was set to non-existing content for one of our two websites in the EPiServer installation; i.e. a content with id 501, which didn’t exist in our template database.
Reverting the code base to a pre-EPiServer Forms commit, and having a look in EPiServer’s edit mode confirmed this. The left pane in the image below is the site with the faulty SiteBlockFolder reference, and the right one is the site where everything was working as it should.
Resetting EPiServer’s Content Folders to get ‘For All Sites’, ‘For This Site’, ‘For this Page’ back
The solution is rather simple. In EPiServer’s Admin mode (Config tab, and Manage Websites option) you have a checkbox called Use site-specific assets if you access the non-working website’s settings. Thanks Thomas Durrani.
Simply click it, save the settings, click it again and save – and your references should be repaired by the EPiServer installation.
This is also confirmed if we have a look in the EPiServer database table tblSiteDefinition.
The first website was the one with the faulty reference. It’s SiteAssetsRoot value was previously set to 501, but was automatically changed to the working reference 542.
Exception Details: EPiServer.Core.ContentNotFoundException: Content with id 501 was not found [ContentNotFoundException: Content with id 501 was not found] EPiServer.Core.DefaultContentLoader.Get(ContentReference contentLink, LoaderOptions loaderOptions) +536 EPiServer.Core.DefaultContentRepository .GetDefault(ContentReference parentLink, Int32 contentTypeID, CultureInfo language) +252 EPiServer.Forms.EditView.InitializationModule .SetupRootFolderForForm() +1036 EPiServer.Forms.EditView.InitializationModule .Initialize(InitializationEngine context) +263 EPiServer.Framework.Initialization.Internal.ModuleNode .Execute(Action a, String key) +64 EPiServer.Framework.Initialization.InitializationEngine .InitializeModules() +387
This was my problem when I installing Episerver Forms after upgrading from Episerver 7 to 10.
The original error was: ‘Content type “SysContentFolder” is not allowed to be created under parent of content type’
Thank you for posting this.