ASP.NET MVC 2 preVIEW 2:区域复制器问题 [英] ASP.NET MVC 2 Preview 2: Areas duplicate controller problem

查看:191
本文介绍了ASP.NET MVC 2 preVIEW 2:区域复制器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我继续奴役MVC 2件事:地区...

Hi I am continuing to enslave the MVC 2 thing: Areas...

现在我有两个控制器,主控制器文件夹相同的名称(HomeController中)和地区之一。两者有不同的命名空间所以......理论上应该并存,但他们没有。
该错误是:

Now I have two controllers with the same name (HomeController) in the main Controllers folder and in one of the Areas. Both have different namespaces so... theoretically should coexists, but they don't. The error is:

控制器名称'家'是以下类型之间的暧昧:

The controller name 'Home' is ambiguous between the following types:

Namespace.HomeController

Namespace.HomeController

Namespace.Areas.AreaName.Controllers.HomeController

Namespace.Areas.AreaName.Controllers.HomeController

这是不相关的家庭控制器仅(特一?),但适用于任何领域的任何一对。

This is not related to Home controller only (special one?), but applies to any pair in any areas.

如何不同的区域内达到相同​​的名称控制器的共存?

How to achieve the coexistence of the same-name-controllers within different areas?

感谢您的时间:)

编辑:
它是没关系相同的控制器名称中不同的领域:与命名空间注册路由解决问题(感谢斯科特的阿伦<一个href=\"http://odeto$c$c.com/Blogs/scott/archive/2009/10/13/asp-net-mvc2-$p$pview-2-areas-and-routes.aspx\"相对=nofollow>文章)。

推荐答案

如果两个控制器具有相同的类名是两个不同的领域,这正常工作。

在你的情况,你必须在一个地区一个控制器,并在默认Controllers文件夹一个控制器。你确定这是你想要的吗?是你的默认的Controllers文件夹应该包含某种共享的控制器,如默认帐户控制器的?

In your case, you have one controller in an area, and one controller in the "default Controllers folder". Are you sure this is what you want? Is your "default Controllers folder" supposed to contain some kind of shared controllers, such as the default account controller?

这是一个真正的ASP.NET路由问题,而不是一个命名空间或类名称的问题。 的问题是最有可能的,你有两条路径不明确的控制器名称;一个通孔经由的RegisterRoutes默认路由登记区登记和一名注册。

This is really an ASP.NET Routing issue as opposed to a namespace or class name issue. The problem is most likely that you have two routes to the ambiguous controller name; one registered via area registration and one via the default route registration in RegisterRoutes.

此外,请参阅this张贴有关地区订购

这篇关于ASP.NET MVC 2 preVIEW 2:区域复制器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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