我对MVC3有个问题
我正在尝试使用@Html.ActionLink()
为我的博客项目中的标题生成一个链接。
在ActionLink
中使用常量字符串非常好用,但是如果我使用Posts.Title
(正在循环的当前Post模型的标题),我会得到这个异常:
CS1973: 'System.Web.Mvc.HtmlHelper<dynamic>' has no applicable method
named 'ActionLink' but appears to have an extension method by that name.
Extension methods cannot be dynamically dispatched. Consider casting
the dynamic arguments or calling the extension method without the
extension method syntax.
发布于 2011-04-29 21:31:51
“考虑强制转换动态参数或调用不使用扩展方法语法的扩展方法。”
Posts.Title没有类型(因此是动态参数)。
只需通过(字符串)Posts.Title转换它。
https://stackoverflow.com/questions/5832692
复制相似问题