2012-12-06 37 views
1
routes.MapRoute(
      name: "GetAdressen", 
      url: "{controller}", 
      defaults: new { controller = "AdressenController", action = "GetAdressen"} 
     ); 
     routes.MapRoute(
      name: "GetEinsaetze", 
      url: "{controller}", 
      defaults: new { controller = "EinsaetzeController", action = "GetEinsaetze"} 
     ); 

在這種情況下,只有/ Adressen會的工作,而不是也/ EinsaetzeMVC路由映射:1 URL模式僅適用於正好1個控制器

 routes.MapRoute(
      name: "GetEinsaetze", 
      url: "{controller}", 
      defaults: new { controller = "EinsaetzeController", action = "GetEinsaetze"} 
     ); 
routes.MapRoute(
      name: "GetAdressen", 
      url: "{controller}", 
      defaults: new { controller = "AdressenController", action = "GetAdressen"} 
     ); 

在這種情況下,只有/ Einsaetze會工作,不也/ Adressen

爲什麼?

回答

0

使用這樣

routes.MapRoute(
       name: "Default", 
       url: "{controller}/{action}/{id}", 
       defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }, 
       namespaces: new[] { "projectName.Controllers" }); 
+0

在我的控制器動作,我只通過的ActionResult返回一個JSON。我不在我的mvc應用程序中使用視圖。 – cdbeelala89