【发布时间】:2016-09-29 18:59:28
【问题描述】:
我正在开发一个 mvc 应用程序,并且在解决路由时遇到多个控制器冲突。只有一个控制器,站点中只有一个 dll 有控制器。这是一个很大的dll,这个dll中有很多控制器。其他 MVC 路线工作正常。为什么会这样?
我知道有 2 个同名的控制器应该被命名空间。我知道拥有一个新旧 dll 都会在应用程序中加载并导致冲突,这不是问题。 - Multiple types were found that match the controller named 'Home'
The request for 'Nelson' has found the following matching controllers:
MyWebsite.Areas.Controllers.NelsonController
MyWebsite.Areas.Controllers.NelsonController
[InvalidOperationException: Multiple types were found that match the controller named 'Nelson'. This can happen if the route that services this request ('Nelson/NelsonGridView/{NelsonGVM}') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter.
The request for 'Nelson' has found the following matching controllers:
MyWebsite.Areas.Controllers.NelsonController
MyWebsite.Areas.Controllers.NelsonController]
//路线
context.MapRoute(
"Nelson 603 Grid View",
"Nelson/NelsonGridView/{NelsonGVM}",
new { controller = this.AreaName, action = "NelsonGridView", NelsonGVM = new NelsonGVM() }
);
示例网址调用:
https://mysite/CR/Nelson/NelsonGridView/
【问题讨论】:
标签: c# .net asp.net-mvc