Google Analytics İzleme

15 Temmuz 2012

mvc 3 makale - Multiple types were found that match the controller named hatası

Yonetim adında Area açtım ve HomeController sınıfı ekledim, eklediğimde aşağıdaki hatayı aldım:

Exception Details: 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:
GsmEgitimi.Web.Controllers.HomeController
GsmEgitimi.Web.Areas.Yonetim.Controllers.HomeController


Çözümü:
Global.asax dosyasında namespace belirterek gerekli çakışmayı engellemiş oluyoruz:


public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new {controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
                , new string[] { "GsmEgitimi.Web.Controllers" }
            );

        }

Kaynak:
http://stackoverflow.com/questions/7842293/multiple-types-were-found-that-match-the-controller-named-home
http://stackoverflow.com/questions/8788014/multiple-types-were-found-that-match-the-controller-named-home-in-two-differ
http://ediblecode.com/blog/dot-net/asp-net-mvc/fixing-multiple-types-were-found-that-match-the-controller-named
http://forums.asp.net/t/1536381.aspx/1?Areas+Duplicated+controller+name
http://metinkacmaz.com/multiple-types-were-found-that-match-the-controller-named-makalesi/143.aspx



Hiç yorum yok: