TheLazyChap
TheLazyChap

Reputation: 1902

Sitecore Habitat how can I create a basic 404 page?

I am trying to create a basic 404 page in Sitecore Habitat, completely stumped and new to Sitecore. I've created this NotFound page in the content tree using a basic page.

I have the following in my Website project. <projectName>.web.config under the app_config > include > project folder.

<settings>
  <setting name="Preview.DefaultSite" value="qube" />
    <!--  ITEM NOT FOUND HANDLER
        Url of page handling 'Item not found' errors
  -->
  <setting name="ItemNotFoundUrl">
    <patch:attribute name="value">/NotFound</patch:attribute>
  </setting>
    <!--  LINK ITEM NOT FOUND HANDLER
        Url of page handling 'Link item not found' errors
  -->
    <setting name="LinkItemNotFoundUrl">
      <patch:attribute name="value">/NotFound</patch:attribute>
    </setting>
    <!--  LAYOUT NOT FOUND HANDLER
        Url of page handling 'Layout not found' errors
  -->
    <setting name="LayoutNotFoundUrl">
      <patch:attribute name="value">/NotFound</patch:attribute>
    </setting>
    <!--  ERROR HANDLER
        Url of page handling generic errors
  -->
    <setting name="ErrorPage">
      <patch:attribute name="value">/NotFound</patch:attribute>
    </setting>
</settings>

I'm getting the following error/stack trace when trying to hit a non-existing URL/page, looking at the network tab in console its a HTTP 500 server error not the 404 that I wanted:

[HttpException (0x80004005): Error executing child request for /NotFound.]
   System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +2292
   System.Web.HttpServerUtility.Execute(String path, TextWriter writer, Boolean preserveForm) +822
   System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm) +76
   System.Web.HttpServerUtility.Transfer(String path) +45
   Sitecore.Pipelines.HttpRequest.ExecuteRequest.HandleItemNotFound(HttpRequestArgs args) +845
   (Object , Object[] ) +74
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +484
   Sitecore.Nexus.Web.HttpModule.(Object , EventArgs ) +525
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +142
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +92

Upvotes: 0

Views: 456

Answers (1)

Gatogordo
Gatogordo

Reputation: 2635

Those settings should not to point to a Sitecore path. If you want to use an item as 404 page, you should create a processor to add to the httpRequestBegin pipeline. More info and code and that topic can be easily found in several blogs, e.g. https://briancaos.wordpress.com/2013/03/21/sitecore-404-without-302/

Or you could use the Sitecore Error Manager module (see https://ctor.io/handling-404-and-other-errors-with-sitecore-items/). Didn't use it myself yet, but it should do what you want.

Upvotes: 0

Related Questions