我正在开发一个mvc应用程序,并且在解析路由时遇到多个控制器冲突。只有一个控制器,并且站点中有一个具有控制器的dll。这是一个很大的dll,这个dll中有很多控制器。其他MVC路线工作正常。为什么会这样?
我知道有两个名字相同的控制器应该是命名空间。我知道有一个新的和旧的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/
答案 0 :(得分:1)
唯一可能的是,你可能会在bin文件夹中找到重复的dll。您是否有机会重命名您的项目名称空间?因为这会触发VS.NET生成新的程序集并将旧程序集并排放在bin文件夹中。
请清理bin文件夹。重建并尝试一下。