0

私は混乱しています。「管理者」という名前の領域を作成し、次の 2 つのコントローラーを持っています。

/admin/users/...

/users/..

この URL にリンクしようとすると、次のようになります。

/users/list

次のエラーが表示されます。

Multiple types were found that match the controller named 'User'. 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 

「名前空間」パラメーター。

なぜそれが機能しないのかわかりません。この UserController がエリアにないものであることがわかりませんか?

4

2 に答える 2

2

領域が導入されると、同じ名前のコントローラー間にあいまいさが生じる可能性があります。参照: http://haacked.com/archive/2010/01/12/ambiguous-controller-names.aspx

これを Global.asax に追加してみてください

public static void RegisterRoutes(RouteCollection routes)
{
  //all your other routes

  routes.MapRoute(
    "Default",                                              // Route name
    "{controller}/{action}/{id}",                           // URL
    new { controller = "Home", action = "Index", id = "" }, // Defaults
    new[]{"Your.NameSpace"}                       // Namespaces
  );
}
于 2013-09-13T20:27:48.263 に答える