Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

How to manage controller/action not found in ASP.NET MVC

0.00/5 (No votes)
21 May 2013 1  
Manage controller/action not found in ASP.NET MVC

Introduction

A common error when we developed web sites is that we forget to manage the error 404 (resource not found), so I will show how to manage this problem easily in ASP.NET MVC.

Using the code

First, create a new ASP.NET MVC 4 Project using the basic template, this template looks like:

Basic template MVC 4

Next, add the package NotFound MVC using Nuget:

NotFound MVC Package using Nuget


When the package is installed, you can see that a new view was create at the folder Views/Shared:

NotFound View

Now, if you run the application, automatically you are sent to the NotFound view:

NoFound View Redirect

The next step, is that you personalize the view.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here