Html.ActionLink不能动态调度 [英] Html.ActionLink cannot be dynamically dispatched

查看:418
本文介绍了Html.ActionLink不能动态调度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有MVC3问题

我试图用 @ Html.ActionLink()来产生在我的博客项目为标题的链接。

ActionLink的使用常量字符串工作只是花花公子,但如果我使用的 Posts.Title (标题目前邮政绕环模型),我得到这个异​​常:

  CS1973:'System.Web.Mvc.HtmlHelper<动态>'没有适用的方法
名为ActionLink的,但似乎有这个名字的扩展方法。
扩展方法不能进行动态调度。考虑铸造
动态参数或调用没有扩展方法
扩展方法的语法。


解决方案

考虑强制动态参数或调用没有扩展方法的语法扩展方法。

Posts.Title不具有式(因此动态参数)。

只是通过(字符串)Posts.Title投放。

I have a problem with MVC3

I'm trying to use @Html.ActionLink() to generate a Link for titles in my blog project.

Using constant strings in ActionLink works just dandy, but if I use Posts.Title (the Title of the current Post model being looped), I get this exception:

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.

解决方案

"Consider casting the dynamic arguments or calling the extension method without the extension method syntax."

Posts.Title doesn't have a type (hence dynamic argument).

Just cast it via (string)Posts.Title.

这篇关于Html.ActionLink不能动态调度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆