Item Not Found

Item Not Found

Item Not Found

  • This setting provides the URL of the page to display when an item in the Content Tree cannot be found
  • The default URL is /sitecore/service/notfound.aspx

Item Not Found Configuration Settings

  • <configuration>
    • <sitecore>
      • <settings>
        • <setting name="ItemNotFoundUrl" value="/sitecore/service/notfound.aspx"/>

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Configuration.Settings
  • Sitecore.Data.Items.Item

Item Not Found C# Web Control Code

Sitecore.Data.Items.Item item = this.GetItem();
if (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);
string displayName = Sitecore.StringUtil.GetString(item.DisplayName, item.Name);
//using &#58; for colon and &#160; for space
output.Write("{0}&#58;&#160;{1}", "Item", displayName);
output.RenderEndTag(); //P

string itemNotFoundUrl = Sitecore.Configuration.Settings.GetSetting("ItemNotFoundUrl");
output.Write("{0}&#58;&#160;{1}", "Item Not Found URL", "<b>" + itemNotFoundUrl + "</b>");

output.RenderEndTag(); //Div


Item Not Found C# Web Control Output

Item Not Found URL: /sitecore/content/Home/PageNotFound