【发布时间】:2014-03-07 22:16:53
【问题描述】:
我已修改路由以在 URL 中包含文化
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}" }
);
我还创建了ErrorController 并在Web.config 中定义了我的错误页面:
<customErrors mode="On" defaultRedirect="~/Error/Index">
<error statusCode="404" redirect="~/Error/NotFound"/>
</customErrors>
我也在使用 mvcSiteMapProvider,所以我已经包含了我的新错误页面,并且能够通过菜单访问它们,因为它使用包含我的文化的 URL:localhost/en-GB/Error/NotFound
当抛出异常时,由于Web.Config 中定义的重定向中缺少文化,因此找不到错误页面。
在重定向到我的错误页面时如何包含文化?
【问题讨论】:
标签: c# asp.net asp.net-mvc routing asp.net-mvc-routing