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
C#, .NET, .Net Core
ASP.NET MVC, ASP.NET Web Forms, ASP.NET Core
HTML 5, CSS 3, Javascript, jQuery, Bootstrap
Entity Framework, NHibernate, Dapper
Sql Server, MySql, Oracle
Windows Server, Ubuntu, Debian, Pardus
Xamarin Forms, Android Studio
--- The future of the open web platform is looking very bright!
--- .NET is a free, cross-platform, open source developer platform for building any app.
Google Analytics İzleme
Kaydol:
Kayıt Yorumları (Atom)
Hiç yorum yok:
Yorum Gönder