我試圖從MVC期貨庫MVC期貨的強類型使用的RenderAction區域和重複控制器名稱
我有我的主要HomeController的一個導航動作(區一個強類型的性質使用Html.RenderAction = 「」),我試圖
<% Html.RenderAction<HomeController>(x=>x.Navigation()); %>
,直到我添加了另一個HomeController的到我的聯繫便攜式區域這真是棒極了,從我的Site.Master調用。然後,我開始了以下錯誤:
Multiple types were found that match the controller named 'Home'. This can happen if the route that services this request 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: Areas.Admin.Controllers.HomeController Web.Controllers.HomeController
我能夠通過以下非mvccontrib強類型的方法的RenderAction來解決該問題。我寧願在頁面上沒有這種非強類型的方法,是否有辦法讓mvccontrib方法接受一個區域,或者讓他們知道根據指定的路由或命名空間生成區域。
<% Html.RenderAction("Navigation", "Home", new { area = "" }); %>
我已經加入到我的Global.asax.cs文件用默認的區域來支持多個控制器,如下圖所示,而我也驗證了這是我的控制器正確的命名空間。
_routeCollection.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional }, new[] { "Web.Controllers" });
不錯的工作!!!!!!! –