2012-05-23 99 views
1

我期待使用下列網址和部分航線相應MVC3地圖路線

<domain>/Home/About 
<domain>/Home/SiteList 
<domain>/Site/<id>/ (this one is defaulted to the details view) 
<domain>/Site/<id>/section1/ (this one goes to section1 route in the Site controller) 
<domain>/Site/<id>/section2/ (this one goes to section2 route in the Site controller) 

e.g. 
<domain>/Site/london/siteinfo 

以上爲

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

但是覆蓋地圖,我也想用以下途徑

<domain>/Site/<siteid>/section1/controller/action (where controller gets data linked to the <siteid> and action is optional) 

示例鏈接將是:

<domain>/Site/london/siteinfo/manager (manager is a controller and will list managers for the site) 

如果嘗試了各種路線並閱讀各種帖子,但無法找到適用於我的任何內容。

任何人都可以提供一些幫助嗎?

感謝 魯迪

+0

是不是你的'{}行動'和'{ID}'切換? – GalacticCowboy

+0

是的,我需要它。他們只會看到「細節」行爲,例如/site/london - 謝謝 – Dudedolf

回答

1

添加下面的 「默認」 多了一個途徑:

routes.MapRoute(
      "MyRouteName",            // Route name 
      "{controller}/{action}/{id}/{section}/{subsection}",       // URL with parameters 
      new { controller = "Home", action = "Index", id= "", section= "", subsection = "" } // Parameter defaults 
     ); 
+0

我在這裏可能是錯的,但是不應該在默認路由上添加任何新路由嗎? – CallumVass

+0

感謝您的回覆,我已經更新了問題,小節應該應該是控制器,並添加了一個URL的例子 – Dudedolf