The controller for path '/Login/Index' was not found or does not implement IController

3

I have a problems used mvc 3 and my application register Area but no functionally when application start get me:

{System.Web.HttpException (0x80004005): The controller for path '/Login/Index' was not 
found or does not implement IController.
   at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType)
   at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName)
   at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<BeginProcessRequest>b__2()
   at System.Web.Mvc.SecurityUtil.<>c__DisplayClassb`1.<ProcessInApplicationTrust>b__a()
   at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f)
   at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
   at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust[TResult](Func`1 func)
   at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
   at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state)
   at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)}
asp.net-mvc
asp.net-mvc-3
asked on Stack Overflow Apr 15, 2013 by user787738 • edited Apr 15, 2013 by Rob

4 Answers

2

This error can occur if the Controller class is declared in the wrong namespace for your Area. Make sure the namespace matches the area registration.

answered on Stack Overflow Oct 18, 2013 by Peter Gluck
1

This is an old questions but I really couldn't find the right answer anywhere else. This was my solution:

I have a solution with multiple projects. All projects were in MVC3. I installed Visual Studio 2012 in my machine and it seems that some projects were automatically upgraded to MVC4.

I got this problem "The controller for path '/etc/etc' was not found or does not implement IController" because the project that handled that route was pointin to MVC4.

I had to manually update their references to use MVC3. You can also do that by opening the .csproj file with a text editor. Find the reference to MVC3 and remove this line:

<SpecificVersion>False</SpecificVersion>

answered on Stack Overflow Nov 1, 2013 by Carlos Martinez T
0

This means that MVC can't find a class that implements IController, whether via the default Controller class, or some other mechanism, that is also named Index in the namespace {DefaultNamespace}.Controllers.Login.

Generally speaking, if you structure your MVC application like the default MVC project structure is, you won't have any issues with this type of thing.

However, if you're using the right folder structure and it's saying this then the Index controller you setup isn't inheriting properly.

This answer is of course assuming you're using the basic default routing that's setup when the project is first created from the template.

answered on Stack Overflow Apr 15, 2013 by Mike Perrenoud
0

In my case the default route new { controller = "Home", action = "Index", id = "" } was pointing to the wrong controller.

Global.asax.cs

protected void Application_Start(object sender, EventArgs e)
{
    AreaRegistration.RegisterAllAreas();
    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    BundleConfig.RegisterBundles(BundleTable.Bundles);
}

RouteConfig.cs

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapMvcAttributeRoutes();

        routes.MapRoute(
            "Default",
            "{controller}/{action}/{id}",
            new { controller = "Home", action = "Index", id = "" }
        );
    }
}
answered on Stack Overflow Jan 2, 2020 by Joel Wiklund

User contributions licensed under CC BY-SA 3.0