Silverlight 3 中区分大小写的 UriMapper 问题
在 Silverlight 3 的导航 API 中,UriMapper 类区分大小写。对于以下 uri 映射,
<nav:Frame Source="/Home">
<nav:Frame.UriMapper>
<uriMapper:UriMapper>
<uriMapper:UriMapping
Uri=""
MappedUri="/Views/HomePage.xaml"/>
<uriMapper:UriMapping
Uri="/entity/{code}"
MappedUri="/Views/EntityEditorPage.xaml?code={code}"/>
<uriMapper:UriMapping
Uri="/{pageName}"
MappedUri="/Views/{pageName}Page.xaml"/>
</uriMapper:UriMapper>
</nav:Frame.UriMapper>
</nav:Frame>
“/entity/123”正确映射到“/Views/EntityEditorPage.xaml?code=123” 但“/Entity/123”将失败,并出现“/Views/Entity/123Page.xaml not found”异常。
如何将 UriMapper 设为不区分大小写?
谢谢。
In Navigation API of Silverlight 3 the UriMapper class is case sensitive. For the following uri mapping
<nav:Frame Source="/Home">
<nav:Frame.UriMapper>
<uriMapper:UriMapper>
<uriMapper:UriMapping
Uri=""
MappedUri="/Views/HomePage.xaml"/>
<uriMapper:UriMapping
Uri="/entity/{code}"
MappedUri="/Views/EntityEditorPage.xaml?code={code}"/>
<uriMapper:UriMapping
Uri="/{pageName}"
MappedUri="/Views/{pageName}Page.xaml"/>
</uriMapper:UriMapper>
</nav:Frame.UriMapper>
</nav:Frame>
the "/entity/123" is correctly mapping to "/Views/EntityEditorPage.xaml?code=123"
but "/Entity/123" will fail with the "/Views/Entity/123Page.xaml not found" exception.
How can I turn the UriMapper to case-insensitive?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Safor,
我完全按照安东尼为我自己的申请所建议的去做。
以下是修改为使用 CustomUriMapper 的 XAML:
以下是 CustomUriMapping 和 CustomUriMapper 类的代码:
祝你好运,Jim McCurdy
Safor,
I did exactly what Anthony suggested for my own application.
Here is your XAML modified to use a CustomUriMapper:
Here is the code for the CustomUriMapping and the CustomUriMapper classes:
Good luck, Jim McCurdy
UriMapper 使用正则表达式,尝试将映射更改为“[V|v]iews/EntityEditorPage.xaml?code={code}” 对于初学者来说,这将使视图中的 V 大小写变得不敏感
UriMapper uses regular expression try changing your mapping to "[V|v]iews/EntityEditorPage.xaml?code={code}" for starters this will make the V in view case insensi
你不能轻易做到这一点。最终,您需要派生自己的
UriMapperBase
并自行完成所有映射逻辑。除非您可以使用一些简化的映射,否则这可能不值得做。You can't do this easily. Ultimately you will need to derive your own
UriMapperBase
and do all the mapping logic yourself. Its probably not a worthwhile thing to do unless you can use some simplified mappings.