Site Info

Site Info

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Configuration.Factory
  • Sitecore.Context
  • Sitecore.Data.Items.Item
  • Sitecore.Sites.SiteContext
  • Sitecore.Web.SiteInfo

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;

Sitecore.Web.SiteInfo siteInfo = Sitecore.Configuration.Factory.GetSiteInfo(site.Name);
if (siteInfo == 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 space
output.Write("{0}: {1}", "Site", site.Name);
output.RenderEndTag(); //P

output.Write("{0}&#58;&#160;{1}", "Name", "<b>" + siteInfo.Name + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Allow Debug", "<b>" + siteInfo.AllowDebug.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Browser Title", "<b>" + siteInfo.BrowserTitle + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Cache HTML", "<b>" + siteInfo.CacheHtml.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Cache Media", "<b>" + siteInfo.CacheMedia.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Disable Client Data", "<b>" + siteInfo.DisableClientData.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "DisableXMLControls", "<b>" + siteInfo.DisableXmlControls.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Enable Analytics", "<b>" + siteInfo.EnableAnalytics.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Enable Debugger", "<b>" + siteInfo.EnableDebugger.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Enable Preview", "<b>" + siteInfo.EnablePreview.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Enable WebEdit", "<b>" + siteInfo.EnableWebEdit.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Enable Workflow", "<b>" + siteInfo.EnableWorkflow.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "HtmlCache Enabled", "<b>" + siteInfo.HtmlCache.Enabled.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Is Active", "<b>" + siteInfo.IsActive.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Physical Folder", "<b>" + siteInfo.PhysicalFolder + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Port", "<b>" + siteInfo.Port.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Registry Cache Enabled", "<b>" + siteInfo.RegistryCache.Enabled.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Require Login", "<b>" + siteInfo.RequireLogin.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Root Path", "<b>" + siteInfo.RootPath + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Start Item", "<b>" + siteInfo.StartItem + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "ViewState Cache Enabled", "<b>" + siteInfo.ViewStateCache.Enabled.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Virtual Folder", "<b>" + siteInfo.VirtualFolder + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Xsl Cache Enabled", "<b>" + siteInfo.XslCache.Enabled.ToString() + "</b>");

output.RenderEndTag(); //Div

C# Web Control Real-time Output

Site: website

Name: website
Allow Debug? True
Browser Title: Website - Sitecore
Cache HTML? True
Cache Media? True
Disable Client Data? False
DisableXMLControls? False
Enable Analytics? True
Enable Debugger? True
Enable Preview? True
Enable WebEdit? True
Enable Workflow? True
HtmlCache Enabled? True
Is Active? True
Physical Folder: /
Port: 0
Registry Cache Enabled? False
Require Login? False
Root Path: /sitecore/content
Start Item: /home
ViewState Cache Enabled? False
Virtual Folder: /
Xsl Cache Enabled? True