Creating custom 404 and error pages has changed in Orchard CMS. Prior to Orchard 1.4 we had to modify our web.config files to allow custom errors and then modify the handlers a bit to get Orchard to actually serve our custom pages. Now all we need to do is override a couple of shapes, NotFound.cshtml and ErrorPage.cshtml, and we have custom 404 and error pages in Orchard in seconds.

Overriding NotFound.cshtml for 404 Not Found Errors

Customizing your Orchard Website is often about overriding shapes and creating shape alternatives. It just makes sense that displaying custom 404 Not Found and Error Pages should be about overriding shapes, too. In Orchard 1.4 you will find a custom shape, called NotFound.cshtml, in your Core -> Shapes -> Views Folder.

Creating Custom 404 Pages in Orchard CMS

By default this shape doesn't say much. Currently it looks as such.


<h1>@Html.TitleForPage(T("Not found").ToString())</h1>
<p>@T("The page you are looking for does not exist.")</p>

You want to override this shape by copying NotFound.cshtml to your theme's Views Folder and modifying it there!

Overriding ErrorPage.cshtml for Custom Error Pages

If you have a keen eye, you probably noticed another shape in the folder that displays custom error pages other than 404. The shape is called ErrorPage.cshtml.

Creating Custom Error Pages in Orchard CMS

And as you would expect, this page is pretty bland, too. It's just waiting for you to override it.

<div>
  <h1 id="page-title">Oops. Something went wrong ... sorry</h1>
  <div>
      <p>
         An unhandled exception has occurred and the
         request was terminated. Please refresh the page.
         If the error persists, go back
      </p>
  </div>
</div>

Go ahead and copy ErrorPage.cshtml to your theme's Views Folder and give it a splash of personality!

Enjoy!