当项目下:Controller/HomeController.cs时,
人在创建一个域Test,之后在建一个同名的HomeController: Areas/Test/Controller/HomeController.cs
运行报错:
Multiple types were found that match the controller named 'Home'. This can happen if the route that services this request ('{controller}/{action}/{id}/') 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 'Home' has found the following matching controllers:
Web.Areas.Test.Controllers.HomeController
Web.Controllers.HomeController
解决办法:
/Areas/Test/TestAreaRegistration.cs
/Global.asax
本文介绍了解决ASP.NET MVC中控制器命名冲突的问题。当在不同命名空间下使用相同名称的控制器时,会导致运行时报错。文章提供了通过配置路由来区分不同命名空间下的控制器的方法。

被折叠的 条评论
为什么被折叠?



