【发布时间】:2011-06-15 12:47:27
【问题描述】:
鉴于强类型 ActionLink 不可行(Strongly Typed ActionLink In Asp.Net MVC 2?),我们不能这样做:
<%: Html.ActionLink<HomeController>(x => x.Index(), "Home") %>
我正在考虑使用static readonly string 类或资源文件作为解决方法。这将获得一定程度的编译时间检查,允许在不使用查找/替换的情况下重命名,甚至(在某些疯狂的世界中)允许本地化。不利的一面是,它需要有关可用控制器和操作的重复信息才能工作。
<%: Html.ActionLink(Controllers.Home, HomeActions.Index, HomeActions.IndexTitle) %>
有什么其他方法可以改进使用魔术字符串的不优雅默认设置吗?
【问题讨论】:
标签: asp.net-mvc