我加入一些.cshtml文件的一些內容(沒有dynamicaly加載,只是一個靜態內容)靜態.cshtml文件
有幾個文件ASP.NET MVC3路線: /視圖是一個目錄 /經銷店是在目錄/瀏覽次數
Views - Dealership - About.cshtml
Views - Dealership - Testimonials.cshtml
Views - Dealership - Audi.cshtml
Views - Dealership - AudiA6.cshtml
Views - Dealership - AudiA8.cshtml
Views - Dealership - BMW.cshtml
Views - Dealership - BMW5.cshtml
Views - Dealership - BMW7.cshtml
網址應:
www.mywebsite.com/dealership/about
www.mywebsite.com/dealership/testimonials
www.mywebsite.com/dealership/audi
www.mywebsite.com/dealership/audi/audi-A6
www.mywebsite.com/dealership/audi/audi-A8
www.mywebsite.com/dealership/bmw
www.mywebsite.com/dealership/bmw/bmw-5
怎樣的路線應該是什麼樣子?我有這樣的:
routes.MapRoute(
"Dealership", // Route name
"dealership/{action}/{id}", // URL with parameters
new { controller = "Dealership", action = "Index", id = string.Empty }); // Parameter defaults
它適用於
www.mywebsite.com/dealership/audi
或
www.mywebsite.com/dealership/testimonials
,但我不知道如何創建路線
www.mywebsite.com/dealership/audi/audi-A6
我希望這不是太混亂;-)
這是不正確的,現在框架認爲audi-a6是一個參數,路由對視圖一無所知,它只知道哪個控制器,動作和路由參數是其他的,Action知道要呈現哪個視圖用戶。 – Joakim 2011-05-31 12:50:22
問題是www.mywebsite.com/dealership/audi route總是贏,即使我使用www.mywebsite.com/dealership/audi/audiA6 – nubm 2011-05-31 12:51:56
@Joakim沒錯,我還沒有見過奧迪/奧迪-A6,對不起 – Faber 2011-05-31 12:59:53