Html.ActionLink cannot be dynamically dispatched

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 04:06:14

问题


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.

回答1:


"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.



来源:https://stackoverflow.com/questions/5832692/html-actionlink-cannot-be-dynamically-dispatched

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!