【发布时间】:2014-07-30 13:42:22
【问题描述】:
我刚刚使用当前的 MvcSiteMapProvider MVC5(来自 nuget,从 MVC4 升级)遇到了一个“问题”。 在创建动态节点时,我曾经在动态节点的 RouteValues 中添加一个路由值“标题” 在我的 DynamicNodeProvider 中。 这在以前的版本中运行良好,但是在尝试此操作时没有出现错误:
An exception of type 'MvcSiteMapProvider.Collections.Specialized.ReservedKeyException' occurred in MvcSiteMapProvider.dll but was not handled in user code
Additional information: The node with key 'someKey' may not add a route value with the key 'title' and value 'someValue' to the RouteValues dictionary because the key is a reserved name. Reserved names are keys that are meant for use internally by MvcSiteMapProvider rather than a dictionary value.
我收到消息,我不应该将“标题”添加为自定义路由参数。 但是,我的完整项目在路由定义中使用“{title}”,我必须将所有内容从标题更改为“{id}”(或其他内容)。
现在我的问题:是否有可能以某种方式将自定义“标题”路由值添加到动态节点?还是根本不可能?
提前致谢!
【问题讨论】:
-
这可能会有所帮助,看看 MVC 5 路由属性,它们与 MVC 4 stackoverflow.com/questions/21276014/… 不同
-
感谢您的回复!但是,使用路由属性仍然需要对我的项目进行大量更改,如果可能的话,我更喜欢“更简单”/更快的解决方案:)(即,添加一个“特殊”参数或类似于 DynamicNode 来实现这一点)跨度>
-
我明白了 - 这是您覆盖 RouteValue 字典中的值的答案stackoverflow.com/questions/13423545/…
-
感谢您的回复!但不幸的是,这不是我想要的。
标签: asp.net-mvc mvcsitemapprovider