12/12/2015

MVC: The controller for path '/' was not found or does not implement IController


Some error messages are no help at all!


While working on a Visual Studio 2013 MVC project I got this error:



When running in Debug mode Visual Studio reports:
An exception of type 'System.Web.HttpException' occurred in System.Web.dll but was not handled in user code.
Additional information: Execution of the child request failed. Please examine the InnerException for more information.

The inner exception: 
{System.Web.HttpException (0x80004005): The controller for path '/' was not found or does not implement IController.
   at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance




A web search returns many possibilities for the error, but none that applied to my project. It turns out I had one of those "forest and trees" problems! I had typed Html.Action instead of Html.ActionLink in a Layouts view. In effect I was asking the layouts view to load a view that used the layouts view that then loaded the layouts view that loaded the view that used the layouts view… Yup, an endless loop.


The error message was not of much help and sent me on a wild goose chase. Once I realized what was going on I made one small edit and was back in business.



.

No comments:

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.