Customizing pipelines to achieve a custom 404 page

When we request for a web page that does not exist in the site, for example, http://sitecorecookbook/test-page/, Sitecore will redirect you to its default document not found page—notfound.aspx with a 302 HTTP status code. Here, we expect that the requested page itself should show page not found content with a 404 status without any redirection.

In this recipe, we will achieve this expected behavior by customizing the <httpRequestBegin> and <httpRequestProcessed> pipelines.

Getting ready

Create a content item, 404-Page, in side the Home item with Title and Body fields. Make sure that you have added Title and Body rendering on it. When the requested page does not exist in our site, we will show this ...

Get Sitecore Cookbook for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.