EPiServer 7 : Installing BVN.404Handler for an MVC Project

Install The Module

First, install the package ‘BVN.404.Hamdler’ via Nuget from the EPiServer Nuget feed:


Next, download the extension and add in BVN.404Handler.MvcContrib plug-in by Mark Everard here.

Add/check the following is in your web.config ‘configSections’ section

<section name="bvn404Handler" type="BVNetwork.FileNotFound.Configuration.Bvn404HandlerConfiguration, BVNetwork.EPi404" />

Change the ‘fileNotFoundPage’ property in the ‘bvn404Handler’ section

By default the BVN plug-in assumes you are using web forms rather than MVC so you will need to change the fileNotFoundPage attribute to point to the page you will create in EPiServer(You can override it with the snippet below BUT remember you need to create an EPiPage called page-not-found)

<bvn404Handler handlerMode="On" fileNotFoundPage="/page-not-found/">
Register your own handler that will be given a chance to
rewrite the url. The type must implement INotFoundHandler
<add name="NameOfHandler" type="Your.Handler.Here" />

Add/Check BVN has been registered in the modules section

To look like this:

<add name="BVNetwork.EPi404" type="BVNetwork.FileNotFound.Handler.CustomFileNotFoundHandler, BVNetwork.EPi404" /> 

Update/Add your httpErrors section

To look like this:

<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/en/page-not-found/" responseMode="ExecuteURL" />

Create The Views, Controllers, View Models andPageType Definition to be able to create the page within EPiServer

I won’t go over step-by-step how to create each of these elements as it will be different based on your project.  You will need to create all the same basics you would for a normal page.

Create Your Page In EPiServer

After you have done all the tedious configuration stuff you will need to create your Error page in EPiServer. When a 404 is encountered, the plug-in will re-direct the user to your EPiServer page.  If that page doesn’t exisit within EPiSever, nothing will be displayed when an error occurs.

Creating your error page involves the same process as an other page except there’s one difference in the controller.  You will need to add the [NotFoundPage] attribute to the class:

public class _404Controller :  BasePageController<_404Page>
public ActionResult Index(_404Page currentPage)
Response.TrySkipIisCustomErrors = true;
Response.StatusCode = 404;
var viewModel = new _404ViewModel(currentPage);
return View("Index", viewModel);

Log into EPiServer and create the page!

In Episerver, create the page using your 404 page type (or whatever you have called or) and named it /page-not-found/ (or whatever you have defined the name to be in the web.config). The URL matches the value you entered in the fileNotFoundPage section in the BVN404Handker section of your web.config.

Test It out

After you create and publish your 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. This should also take your page can not be found page.

To check the re-direct part of the module works as excepted, log into EPiServer and on the Dashboard tab if you click on new Gadget you should be able to see the custom redirect manager:


Issues I Encountered

After using the BVN.404Handler module it broke my deployment centre. Whenever I tried to create a new sample site all I would get on page load was a 505 error.  To fix the issue after you have installed the site, in the IIS entry for the website, go to modules and remove the BVNNetwork.EPi404 entry. Your newly created site should now load 🙂

Here’s my working code sample… enjoy 🙂 DOWNLOAD HERE

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

More Posts

9 replies
  1. Paul
    Paul says:

    Hi, Wondering if you can help please? I have installed the redirects custom gadget and instead of manually entering each redirect manually i have created a little program that creates an xml file. I have thousands to insert so i thought that this was the best approach. However, i keep getting an error when uploading my xml file which contains 2,500 redirect (327kb). If i reduce it to 10 entries it uploads fine. Is the a setting i can change anywhere to allow me to upload larger files?

    Any help would be awesome on this



  2. Andrew
    Andrew says:

    Hi, I’m having issues with querystrings being lost once redirected. I’ve tried to implement INotFoundHandler to overcome the querystring issue but it doesn’t seem to fire?

    Any suggestions? I’m using EPiServer 8.2

    Thanks in advance,

      • SHane
        SHane says:

        Hi Jon,
        Thanks for the reply.

        A page will be indexed by Google when its not expired

        After expiry, anyone following the link after a Google search gets redirected to the login page (302)

        Google will not remove that page from its index – it needs to get a 404 to indicate that it should be removed.

        So I think the expired page should return a 404 (not found) not a 302

        This is really an EpiServer fault but it would be really useful if your code can fix it.

        • jon
          jon says:

          OK I see what your saying. I’m not sure the plug-in was ever designed to do that.. however.. if you really want that functionality in your site you could do it manually fairly easily. Without properly looking at it I’m pretty confident you could create an intilization module and hook into the routing pipeline and create a 404 rather than a 302 fairly easily. The other option maybe a base page but I”m not sure if the pages controller is ever called on an expired page without testing it.

          If I find the time I can write a guide on it at some point but it may not be for a while 🙂


Trackbacks & Pingbacks

  1. […] BVN. I wrote a comprehensive guide to installing and using the handler a few years’ ago in, Installing BVN.404Handler for an MVC Projec. As time has passed and the plug-ins improved, some of the information is a little outdated. BVN […]

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *