In this tutorial, you will learn how to install the BVN handler package for Episerver CMS. This package will allow a content editor to manage redirects within the CMS. It will also allow for a better 404 experience. You will be able to use a page created within the CMS that is content editable to be served as the site 404 page πŸ”₯πŸ”₯πŸ”₯. The plug-in is free, so why not use it?

Installation of BVN.404.Handler is done via NuGet. This package lives in the Episerver NuGet feed, rather than the normal .NET NuGet feed. Make sure you have the Episerver feed in your Nuget sources within Visual Studio otherwise you will not be able to find it!

You should also download the BVN.404Handler.MvcContrib plug-in written by Mark Everard here (Post 2018 this is no longer needed). After installing the package, you will need to configure it. Add the following config in your web.config, configSections section:

Change the fileNotFoundPage property in the bvn404Handler section. By default, the BVN packages assume that you are using web forms rather than MVC. You will need to change the fileNotFoundPage attribute to point to a page. Remember, you need to create this page within the CMS otherwise a 404 error will be thrown 😹

Next, you will need to register the BVN module within the modules section. Update the config so it looks something like this:

Next, you need to update the httpErrors section to look like this:

Finally, you will need to create a 404 page within the CMS. This is the same as creating any other page type. You will need to create a view file, a corresponding controller, the page-type definition and for brownie points a view model. I won't go into detail on how to create a page in Episerver in this tutorial, as you can find one here.

When a 404 is thrown, the plug-in will re-direct the user to this Episerver page. If that page doesn't exist within Episerver, nothing will be displayed and a blank page will be served. There is one difference when it comes to creating this 404 page within Episerver. The controller will need to be decorated with the [NotFoundPage] attribute, like this:

With your new page type defined, log into Episerver and create the 404-page using the new page type. Set the slug to be whatever you want. I usually call mine /page-not-found/. Remember, the URL needs to match the value you entered in the fileNotFoundPage section in the web.config.

After you create and publish the page, you should be able to test it out. First, open your site and make sure you can navigate to your error page normally. If you can't you may have to repeat some of the steps above. When you can browse to the page normally, it's time to add in an invalid URL. An invalid URL should also redirect you to the same page.

To check the re-direct part of the module is working, log in to Episerver. On the dashboard tab, click on the new Gadget option. From the modal you should be able to see an option called custom redirect manager as seen below:


The plugin is now installed and working πŸ’₯πŸ’₯πŸ’₯. Happy Coding 🀘


After using the BVN.404Handler module it broke my deployment centre. Whenever I tried to create a new sample site allΒ I would encountered a 505 error.Β  To fix the issue, after you have installed the site, within the IIS entry for the website, go to modules and remove the BVNNetwork.EPi404 entry.