Thursday, December 22, 2005

Default Content Database


When you try running the code, the default context is set to the website. This means that all database definitions are taken from the website web.config section: ... name="website" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/home" language="en" database="web" domain="extranet" allowDebug="true" cacheHtml="true" ... As can be seen, the content attribute is missing here, that’s why the content database is undefined. In other words, Sitecore.Context.ContentDatabase returns null. So the following actions can be taken in order to solve the problem: 1. Change the context to the site where the content database is defined. Here is statement to be used before calling Sitecore.Context.ContentDatabase property: Sitecore.Context.SetActiveSite("shell"); or Sitecore.Context.SetActiveSite("modules_shell"); 2. Add the content attribute like it is shown below: ... name="website" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/home" language="en" database="web" domain="extranet" allowDebug="true" content="master" cacheHtml="true" ...

1 comments:

database said...

I liked your posting about mysql

I hope you have backed up your database, don't let it crash and disapear like I did, read about how I lost my database, and how I now have a great new tool to backup my database automatically http://www.databasebackup.co.uk