ASP.NET MVC 複製MVC項目代碼到同一個項目的時候報錯The request for ‘home’ has found the following matching controll

來源:互聯網
上載者:User

標籤:hand   4.0   ring   c項目   opera   handle   frame   程式   技術   

 ASP.NET MVC 複製MVC項目代碼到同一個項目的時候報錯The request for ‘home’ has found the following matching controll“/”應用程式中的伺服器錯誤。 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:
ET_Fund.M.Controllers.HomeController
ET_Fund.Mv3.Controllers.HomeController

說明: 執行當前 Web 請求期間,出現未處理的例外狀況。請檢查堆疊追蹤資訊,以瞭解有關該錯誤以及代碼中導致錯誤的出處的詳細資料。

異常詳細資料: System.InvalidOperationException: 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:
ET_Fund.M.Controllers.HomeController
ET_Fund.Mv3.Controllers.HomeController

源錯誤:

 

執行當前 Web 請求期間產生了未處理的例外狀況。可以使用下面的異常堆疊追蹤資訊確定有關異常原因和發生位置的資訊。


堆疊追蹤:

 

[InvalidOperationException: 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:ET_Fund.M.Controllers.HomeControllerET_Fund.Mv3.Controllers.HomeController]   System.Web.Mvc.DefaultControllerFactory.GetControllerTypeWithinNamespaces(RouteBase route, String controllerName, HashSet`1 namespaces) +429733   System.Web.Mvc.DefaultControllerFactory.GetControllerType(RequestContext requestContext, String controllerName) +576   System.Web.Mvc.DefaultControllerFactory.System.Web.Mvc.IControllerFactory.GetControllerSessionBehavior(RequestContext requestContext, String controllerName) +61   System.Web.Mvc.MvcRouteHandler.GetSessionStateBehavior(RequestContext requestContext) +157   System.Web.Mvc.MvcRouteHandler.GetHttpHandler(RequestContext requestContext) +33   System.Web.Mvc.MvcRouteHandler.System.Web.Routing.IRouteHandler.GetHttpHandler(RequestContext requestContext) +12   System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +9836207   System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +82   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +141   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

 

版本資訊: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.6.1073.0

 

 

解決方案:

 

 1 public static void RegisterRoutes(RouteCollection routes) 2 { 3 //routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 4   5 //routes.MapRoute( 6 // name: "Default", 7 // url: "{controller}/{action}/{id}", 8 // defaults: new { controller = "home", action = "Index", id = UrlParameter.Optional } 9 //);10  11 routes.IgnoreRoute("{resource}.axd/{*pathInfo}");12  13 routes.MapRoute(14 name: "Default",15 url: "{controller}/{action}/{id}",16 defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },17 namespaces: new[] { "ET_Fund.Mv3.Controllers" }  // 此處的 et_fund.mv3 為新的控制器的名詞18 );19 }

 

 原創: 文章來自:

http://www.lesg.cn/wentiji/2017-909.html

 

ASP.NET MVC 複製MVC項目代碼到同一個項目的時候報錯The request for ‘home’ has found the following matching controll

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.