Site Properties

Site Properties

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Context
  • Sitecore.Data.Items.Item
  • Sitecore.Sites.SiteContext

Site Properties C# Web Control Code

Sitecore.Sites.SiteContext site = Sitecore.Context.Site;
Sitecore.Data.Items.Item item = Sitecore.Context.Item;
if (site == null || item == null) return;

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.Write("C# Web Control Real-time Output");
output.RenderEndTag();

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
//using : for colon and ? for question mark and   for space
output.Write("{0}: {1}", "Site", site.Name);
output.RenderEndTag(); //P

output.Write("{0}&#58;&#160;{1}", "Allow Debug", "<b>" + site.AllowDebug.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Browser Title", "<b>" + site.BrowserTitle + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Cache HTML", "<b>" + site.CacheHtml.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Cache Media", "<b>" + site.CacheMedia.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "HTML Cache Enabled", "<b>" + site.Caches.HtmlCache.Enabled.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Filtered Items Cache Count", "<b>" + site.Caches.FilteredItemsCache.InnerCache.Count.ToString() + "</b><br/>");
if (site.ContentDatabase != null)
    output.Write("{0}&#58;&#160;{1}", "Content Database", "<b>" + site.ContentDatabase.Name + "</b><br/>");
if (site.ContentLanguage != null)
    output.Write("{0}&#58;&#160;{1}", "Content Language", "<b>" + site.ContentLanguage.Name + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Content Start Item", "<b>" + site.ContentStartItem + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Content Start Path", "<b>" + site.ContentStartPath + "</b><br/>");
if (site.Database != null)
    output.Write("{0}&#58;&#160;{1}", "Database Name", "<b>" + site.Database.Name + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Default Device", "<b>" + site.DefaultDevice + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Client Store Data", "<b>" + site.DisableClientData.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Filtering Disabled", "<b>" + site.DisableFiltering.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "WebEdit Editing Disabled", "<b>" + site.DisableWebEditEditing.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "XML Controls Disabled", "<b>" + site.DisableXmlControls.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Display Date", "<b>" + site.DisplayDate.ToShortDateString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Display Mode", "<b>" + site.DisplayMode.ToString() + "</b><br/>");
if (site.Domain != null)
    output.Write("{0}&#58;&#160;{1}", "Security Domain", "<b>" + site.Domain.Name + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Analytics Enabled", "<b>" + site.EnableAnalytics.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Debugger Enabled", "<b>" + site.EnableDebugger.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Preview Enabled", "<b>" + site.EnablePreview.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "WebEdit Enabled", "<b>" + site.EnableWebEdit.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Workflow Enabled", "<b>" + site.EnableWorkflow.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Hostname", "<b>" + site.HostName + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Language", "<b>" + site.Language + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Login Page", "<b>" + site.LoginPage + "</b><br/>");
if (site.MasterDatabase != null)
    output.Write("{0}&#58;&#160;{1}", "Master Database Name", "<b>" + site.MasterDatabase.Name + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Media Cache Path", "<b>" + site.MediaCachePath + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Notifications Disabled", "<b>" + site.Notifications.Disabled.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Physical Folder", "<b>" + site.PhysicalFolder + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Site Requires Login", "<b>" + site.RequireLogin.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Layouts Base Path", "<b>" + site.Resources.Layouts.BasePath + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Renderings Base Path", "<b>" + site.Resources.Renderings.BasePath + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Sublayouts Base Path", "<b>" + site.Resources.Sublayouts.BasePath + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Root Path", "<b>" + site.RootPath + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Start Item", "<b>" + site.StartItem + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Start Path", "<b>" + site.StartPath + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Target Host Name", "<b>" + site.TargetHostName + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Virtual Folderl", "<b>" + site.VirtualFolder + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "XML Control Page", "<b>" + site.XmlControlPage + "</b>");
output.RenderEndTag(); //Div


Site Properties C# Web Control Output

Allow Debug: True
Browser Title: Website - Sitecore
Cache HTML? True
Cache Media? True
HTML Cache Enabled? True
Filtered Items Cache Count: 0
Content Language: 
Content Start Item: 
Content Start Path: /sitecore/content
Database Name: web
Default Device: 
Client Store Data: False
Filtering Disabled? False
WebEdit Editing Disabled? False
XML Controls Disabled? False
Display Date: 10/7/2014
Display Mode: Normal
Security Domain: extranet
Analytics Enabled? True
Debugger Enabled? True
Preview Enabled? True
WebEdit Enabled? True
Workflow Enabled? True
Hostname: 
Language: en
Login Page: 
Media Cache Path: /App_Data/MediaCache/website
Notifications Disabled? False
Physical Folder: /
Site Requires Login? False
Layouts Base Path: /sitecore/layout/layouts
Renderings Base Path: /sitecore/layout/renderings
Sublayouts Base Path: 
Root Path: /sitecore/content
Start Item: /home
Start Path: /sitecore/content/home
Target Host Name: 
Virtual Folderl: /
XML Control Page: /layouts/xmlcontrol.aspx