The controller for path was not found or does not implement IController

前端 未结 20 2476
一个人的身影
一个人的身影 2020-11-29 20:50

I have an MVC4 project with language selection:

  • en
  • nl
  • fr
  • de

1 main part with:

  • About
  • Common (fo
20条回答
  •  無奈伤痛
    2020-11-29 21:32

    I've found it.

    When a page, that is located inside an area, wants to access a controller that is located outside of this area (such as a shared layout page or a certain page inside a different area), the area of this controller needs to be added. Since the common controller is not in a specific area but part of the main project, you have to leave area empty:

    @Html.Action("MenuItems", "Common", new {area="" }) 
    

    The above needs to be added to all of the actions and actionlinks since the layout page is shared throughout the various areas.

    It's exactly the same problem as here: ASP.NET MVC Areas with shared layout

    Edit: To be clear, this is marked as the answer because it was the answer for my problem. The above answers might solve the causes that trigger the same error.

提交回复
热议问题