我剛開始使用MVC 3,並且想創建一個像'http:// server/news/9635/demo-news-title'這樣的url,但我不知道如何才能地圖路線。MVC 3 URL路由
routes.MapRoute(
"news",
"{controller}/{id}/{title}",
new { controller = "news", action = "Index", id = UrlParameter.Optional, title = UrlParameter.Optional }
);
我試過了,但它似乎沒有工作。我該怎麼辦?
感謝
什麼是 '不工作'?你是否得到例外?找到錯誤的控制器?你期望什麼具體沒有發生? – dougajmcdonald
當我向瀏覽器寫入'/ news/221/demo-title'時,出現「服務器錯誤/應用程序」錯誤。 mapRoute方法適用於我上面寫的url嗎? – mehmetserif
你能告訴我們你的控制器動作嗎? – frennky