我一直在使用Route Debugger測試幾個選項,但沒有運氣。讓我來描述一下我想:Asp.Net Mvc路由問題
我已經全部路線「翻譯」如下(我需要從英語翻譯成葡萄牙語和某個簡化):
routes.MapRoute("Article.Create", "cms/artigo/criar",
new { controller = "Article", action = "Create" });
一切工作。由於我定義了所有路由,我認爲我不需要默認路由。所以,我有這樣的:
// Other translation routes
routes.MapRoute("Article.Create", "cms/artigo/criar",
new { controller = "Article", action = "Create" });
routes.MapRoute("Article.Edit", "cms/artigo/editar/{id}",
new { controller = "Article", action = "Edit", id = "" });
routes.MapRoute("Home.Index", "inicio",
new { controller = "Home", action = "Index" });
routes.MapRoute("Home.Contact", "contacto",
new { controller = "Home", action = "Contact" });
// Error Unknown
routes.MapRoute("Error.Unknown", "erro",
new { controller = "Error", action = "Unknown" });
// Start
routes.MapRoute("Start", "_Default.aspx",
new { controller = "Home", action = "Index" });
// Error NotFound
routes.MapRoute("Catch.All", "{*path}",
new { controller = "Error", action = "NotFound", path = "" });
如果根穿過轉換映射不匹配,那麼,如果它是一個未知的錯誤只顯示「http://domain.com/erro」
如果沒有,那麼嘗試匹配首頁/索引。
最後去捕獲所有路線,如下「http://domain.com/the/invalid/path
在我的web.config我有隻顯示路徑:
<customErrors mode="On" defaultRedirect="~/Error/Unknown">
<error statusCode="404" redirect="~/Error/NotFound" />
</customErrors>
會發生什麼事,當我開始我的網站總是去NOTFOUND誤差而不是啓動頁。
我在做什麼錯?
如果您可以編輯問題並修改代碼使其顯示爲代碼,會更容易。點擊101010按鈕並將代碼粘貼在那裏 – Luke101 2009-11-14 03:25:57
爲什麼你不使用有問題的代碼小部件來突出顯示你的代碼 – 2009-11-16 03:58:56