为路径,控制器没有被发现,或者不执行一个IController [英] The controller for path was not found or does not implement IController

查看:1978
本文介绍了为路径,控制器没有被发现,或者不执行一个IController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有语言选择的MVC4项目:

I have an MVC4 project with language selection:


  • 连接

  • NL

  • FR


1主要部分用:


  • 关于

  • 通用​​(为菜单)


  • 常见问题

  • 首页

和3个领域:


  • 管理

  • 客户

  • 商店

在每个领域我至少有一个控制器,例如在管理我的控制器的概述与包含指数对应的视图文件夹中的概述。 ASPX

In each area I have at least one controller, for example in Admin I have the controller overview with the corresponding view folder overview which contains an index.aspx page.

主页和所有的主要页面(约,常见问题解答等)工作,并可以参观)。

The home page and all the main pages (about, faq, etc.) work and can be visited).

然而,当我按照网址:本地主机:XXXX / EN /管理/概述
我得到的错误

However, when I follow the url: localhost:xxxx/en/admin/overview I get the error

The controller for path '/en/admin/overview' was not found or does not implement IController.

虽然,路线是正确的(我可以看到这个与路线调试器)。错误页面还显示,当我想我的加载主菜单项的错误被抛出:

Even though, the route is correct (I can see this with Route Debugger). THe error page also shows that the error was thrown when I wanted to load my main menu items:

<nav id="site-navigation" class="eightcol">
    @Html.Action("MenuItems", "Common")
</nav>

- code删除,因为不​​相关的 -

-- Code removed because irrelevant --

一切似乎是为了,但MVC似乎并不能够加载菜单,它位于主要部分。

Everything seems to be in order, but MVC doesn't seem to be able to load the menu, which is located in the main part.

因此​​,问题的根源是:
我可以授予一个地区我的项目(​​例如管理员)访问的主要部分的控制器(家中,常见的,约等)?

So, the root of the problem is: Can I grant an area (e.g. Admin) access to the controllers in the main part (home, common, about, etc.) of my project?

推荐答案

我发现它。

当一个页面中,位于​​一个区域内,想要访问位于该区域以外的控制器(如共享布局页面或不同的区域内的某些页),此控制器的区域需要加入。
由于共同的控制器是不是在一个特定的区域,但主要项目的一部分,你必须离开区域空:

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="" }) 

上面的需要被添加到所有的行动和actionlinks由于布局页面贯穿各区域共享

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

这正是这里同样的问题:
ASP.NET MVC区与共享的布局

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.

这篇关于为路径,控制器没有被发现,或者不执行一个IController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆