2016-08-09 13 views
0
 routes.MapRoute(
     "Default", 
      "{controller}/{action}/{id}", 
     new { controller = "Home", action = "Index", id = UrlParameter.Optional }, 
     new string[] { "Teng.Web.Controllers" }); 


     routes.MapRoute(
      "CMSArticle", 
      "{Classify}/{controller}/{action}/{id}", 
      new { Classify = @"", controller = "Home", action = "Index", id = UrlParameter.Optional }, 
      new string[] { "Teng.Web.Controllers" }); 

CMSArticle Passend http://localhost:4848/ss/home/index/5NET MVC RegisterRoutes Regel

Ich möchte http://localhost:4848/ss/home/index gehen CMSArticle Routen

+0

wenn http: // localhost: 4848/home/index/5 gehen zu Standardrouten –

Antwort

0

ist einen tatsächlichen Parameter klassifiziert? Ich glaube, dass sie in der Reihenfolge ihrer Wichtigkeit sein müssen. Wenn die Route nicht zu einer übereinstimmt, fällt sie auf die nächste. Probieren Sie das unten.

routes.MapRoute(
       "CMSArticle", 
       "ss/{controller}/{action}/{id}", 
       new { controller = "Home", action = "Index", id = UrlParameter.Optional }, 
       new string[] { "Teng.Web.Controllers" }); 

routes.MapRoute(
      "Default", 
       "{controller}/{action}/{id}", 
      new { controller = "Home", action = "Index", id = UrlParameter.Optional }, 
      new string[] { "Teng.Web.Controllers" }); 

Sie können auch bestimmte Controller/Aktion in der Route festgelegt, so dass es Arbeit für alle Steuerungen doens't und/oder Aktionen.

+0

Er sollte nicht nicht gefunden werden Standard CMSArticle gehen innen, um es zu finden? Weil ss nicht behoben ist –

+0

Wenn es nicht behoben ist, warum nicht einfach einen anderen Controller hinzufügen? SSController vielleicht und verwenden Sie das Standard-Routing. localhost: 4848/ss/Index/{id} oder einfach localhost: 4848/ss/{id} – Dillon

+0

danke, ich habe mich damit beschäftigt –