0
我已經修改了我的路由,以包括在MVC錯誤頁面控制器和自定義路由
routes.MapRoute(
name: "Default",
url: "{culture}/{controller}/{action}/{id}",
defaults: new { culture = "en-GB", controller = "StyleGuide", action = "Template", id = UrlParameter.Optional },
constraints: new { culture = @"[a-z]{2}-[A-Z]{2}" }
);
我也曾在Web.config
創建ErrorController
和定義我的錯誤頁的URL文化:
<customErrors mode="On" defaultRedirect="~/Error/Index">
<error statusCode="404" redirect="~/Error/NotFound"/>
</customErrors>
我我也使用mvcSiteMapProvider,所以我已經包含了我的新錯誤頁面,並且能夠通過菜單訪問它們,因爲它使用包含我的文化的URL:localhost/en-GB/Error/NotFound
當拋出異常時,錯誤頁面未找到,因爲Web.Config
中定義的重定向缺少文化。
如何在重定向到錯誤頁面時包含文化?
我會很快看一下這一點,並儘快給您 - 感謝您的回答! –
感謝您及時回覆他們 – nathanchere