Difference between Sitecore.Context.ContentDatabase and Sitecore.Context.Database

Here we will see something related to sitecore context. As we know the properties of Sitecore context indicate a variety of information including the current managed web site, database accessed, security context and the content item requested including language and version.

In Sitecore desktop and Content Editor, you can access the content database through the Sitecore.Context.ContentDatabase property. In user interfaces the context database is always CORE and the Content database is MASTER by default, but in Sitecore desktop an administrator can select a database using the icon on the taskbar and change the database to the required one.

Now the difference between the context database and the content database is especially important when developing Sitecore user interface components. For example you want to show publishing icons(ie. whether an item is published / unpublished / modified) in the gutter(quick action bar) of content tree. Now it does not make sense to show these icons when CORE / WEB database is selected by administrator and so you can use Sitecore.Context.ContentDatabase to know which database has been selected at present and perform the required task.

Happy sitecore learning!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s