ASP.net 路由和全球化
以下文件:
~/Admin/Dashboard.aspx
~/Admin/Welcome.aspx
路由
administrator/{culture}/dashboard/
administrator/{culture}/welcome/
administrator/dashboard/ (for invariant culture)
administrator/welcome/ (for invariant culture)
作为SiteMap
/administrator/dashboard/
/administrator/welcome/
来自站点地图的信息被加载到树控件中。
场景
用户从列表控件中选择法语作为所需语言,该语言保存在会话中。
问题
如何在导航(树形控件)中体现变化?
administrator/fr/dashboard/
administrator/fr/welcome/
我正处于基页面类中的 InitializeCulture() 事件的中间。我本可以使用 Response.Redirect 并对树的数据绑定事件执行丑陋的查找和替换,但这一定不是这样做的正确方法。
非常感谢评论。
The following files:
~/Admin/Dashboard.aspx
~/Admin/Welcome.aspx
are routed as
administrator/{culture}/dashboard/
administrator/{culture}/welcome/
administrator/dashboard/ (for invariant culture)
administrator/welcome/ (for invariant culture)
SiteMap
/administrator/dashboard/
/administrator/welcome/
The information from site map is loaded into a tree control.
Scenario
A user chooses French as desired language from a list control, which is saved in session.
Problem
How to reflect the change in the navigation (tree control)?
administrator/fr/dashboard/
administrator/fr/welcome/
I am in the middle of InitializeCulture() event in base page class. I could have used Response.Redirect and perform an ugly find and replace to tree's databind event, but that must not be a proper way to do so.
Comments are more than appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好问题。站点地图和 URL 重写(路由)效果不佳。
[1] 实现一个以页面路径为参数并返回正确的url重写路径的方法:
[2] 在站点地图中使用普通 url。 /Admin/Dashboard.aspx
[3] 当您绑定树时,您需要使用
GetUrl
方法来更新您的网址。如果您使用站点地图路径,也将以同样的方式处理。
这就是我在大多数项目中所做的。
Good question. Sitemaps and url rewrite (routing) doesn't play well.
[1] implement a method which can take page path as argument and returns correct url rewritten path:
[2] in sitemap use normal urls. /Admin/Dashboard.aspx
[3] when you bind tree, you need to use
GetUrl
method to update your urls.Same way if you are using sitemappaths, that will also be handled in same way.
That's how I am doing in most of the projects I have.