【发布时间】:2012-10-30 09:02:24
【问题描述】:
我有这个文件:
<fru>
<url action="product" controler="Home" params="{id=123}" >this_is_the_an_arbitrary_url_of_a_product.html</url>
<url action="customer" controler="Home" params="{id=445}" >this_is_the_an_arbitrary_url_of_a_customer.html</url>
... other urls ...
</fru>
我正在寻找将此文件或此对象结构与 MVCHandler 绑定,以便将请求映射到具有参数的良好操作。 url 不遵守任何结构规则,这对我来说很重要。
有没有办法做到这一点?
【问题讨论】:
-
需要直接使用XML文件吗?或者你只是用它来说明一组路线?
-
我可以使用
的字典,但你说得对,它只是为了说明一组路线 -
好吧,如果你有一个
Dictionary<string, RouteInfo>,它真的就像循环遍历它并在每个条目上调用routes.MapRoute(...)一样简单。请参阅下面的答案。
标签: asp.net-mvc asp.net-mvc-3 routes