nopCommerce Tips: Adding a Custom 404 Page
Written by Carole Bennett Monday, 1 October 2012
It’s highly recommended for a website to have a customized 404 page. Customized 404 pages provide an opportunity to re-direct site visitors to areas of interest and focus, and maintain branding visibility. At this time, nopCommerce (2.65) doesn’t have a built-in 404 customization solution. However, there is a way to implement one, using the MVC framework nopCommerce is based on.
I’d like to express my appreciation to nopCommerce forum user “Threadrock“, who posted the link to Dave Bouwman’s how-to article “Custom 404 Pages for ASP.NET MVC 3“. In this article, Dave Bouwman covers the steps to create your custom 404 route for an MVC solution. Since nopCommerce is based on Asp.Net MVC, you’ll find the detailed explanation to be very helpful. In the following summary, it’ll be assumed that you’re working from Visual Studio 2010, working on the source version (which can be downloaded from here).
To cover the highlight steps:
1. Open your nopCommerce solution in Visual Studio 2010
2. Locate and open the global.asax file, under Nop.Web.
3. Find the Application_Error method that’s already been started
4. Above the call to “LogException”, add additional error handling along the lines of that which is referenced in Dave’s article. Remember that you’ll also need to add an error controller in the Controllers folder under Nop.Web
5. Add your error controller, as well as your custom view under the Views folder.
For some tips on creating a great custom 404 page, check out this article, “Improving 404 Page Design”.