2012-01-21 7 views
6

यह शायद कई लोगों के लिए एक डुप्लिकेट है लेकिन उनमें स्पष्ट उत्तरों मेरी समस्या का समाधान नहीं करते हैं।कई प्रकार पाए गए जो 'होम' नामक नियंत्रक से मेल खाते हैं। (दो क्षेत्र, समान नियंत्रक का नाम)

मैं:

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: 
App.Web.Controllers.HomeController 
App.Web.Areas.Mobile.Controllers.HomeController 

मैं सेटअप मेरी HomeController के लिए एक डिफ़ॉल्ट नाम स्थान है Global.ascx.cs में:

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

(सत्यापित है कि App.Web.Controllers.HomeController नहीं है एक लेखन त्रुटि)।

और यह भी MobileAreaRegistration में मोबाइल के HomeController पंजीकृत:

public override void RegisterArea(AreaRegistrationContext context) { 
    context.MapRoute(
     "Mobile_default", 
     "Mobile/{controller}/{action}/{id}", 
     new { controller = "Home", action = "Index", id = UrlParameter.Optional } 
    ); 
} 

इसलिए, क्यों यह है कि मैं अभी भी त्रुटि संदेश दिखाई है? मैंने बनाया/साफ किया है और फिर से भाग गया है। अभी भी वही परिणाम।

यह कैसे मैं अपने मार्गों रजिस्टर है:

protected void Application_Start() 
{ 
    AreaRegistration.RegisterAllAreas(); 

    RegisterGlobalFilters(GlobalFilters.Filters); 
    RegisterRoutes(RouteTable.Routes); 
} 
+0

किस क्रम में आप अपने मार्ग पंजीकृत करते हैं? शायद आप पूरा पंजीकरण कोड दिखा सकते हैं? – Jan

उत्तर

14

स्पष्ट कारणों के लिए अपने Global.asax मार्ग पंजीकरण में बदल देते हैं:

साथ
new string[] { "App.Web.Controllers.HomeController" } 

:

new string[] { "App.Web.Controllers" } 

एक namespace है कि बाधा है कि आपको वहां एक विशिष्ट प्रकार का उपयोग नहीं करना चाहिए।

+0

यह है, धन्यवाद! –

संबंधित मुद्दे

 संबंधित मुद्दे