Html.ActionLink 无法动态调度

2024-04-17

我的 MVC3 有问题

我正在尝试使用@Html.ActionLink()为我的博客项目中的标题生成链接。

在中使用常量字符串ActionLink效果很好,但如果我使用Posts.Title(当前帖子模型的标题被循环),我得到这个异常:

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.

“考虑转换动态参数或在不使用扩展方法语法的情况下调用扩展方法。”

Posts.Title 没有类型(因此是动态参数)。

只需通过 (string)Posts.Title 进行投射即可。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Html.ActionLink 无法动态调度 的相关文章

随机推荐