我'我只是使用属性路由,真的可以'得到一些工作路线
这是我的 ProjectsController.cs 路由属性
[RouteArea("Admin")]
[Route("Projects/{action}/{id?}")]
public class ProjectsController : Controller
这是我的 RepresentativesController.cs 路由属性
[RouteArea("Admin")]
[RoutePrefix("Projects")]
[Route("Representatives/{action}/{id?}")]
public class RepresentativesController : Controller
这是文件夹结构(虽然不应该这样):
-Areas
|-Admin
|-Controllers
|-ProjectsController.cs
|-RepresentativesController.cs
我可以'设法浏览此Url例如
/Admin/Projects/Representatives/Index
因为我一直收到这个错误:
Multiple controller types were found that match the URL. This can happen if attribute routes on multiple controllers match the requested URL.
The request has found the following matching controller types:
FasecItaliaLabMVC.Areas.Admin.Controllers.ProjectsController
FasecItaliaLabMVC.Areas.Admin.Controllers.RepresentativesController
我该如何解决这个问题?
答案 0 :(得分:0)
修改路线,可能的选项:
{id?}
移除[Route("Projects/{action}/{id?}")]
,因为目前{id?}
与index
匹配。[Route("Projects/Main/{action}/{id?}")]
[RoutePrefix("Projects")]
很难说出单一的解决方案,这取决于您的控制器。