Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
397 views
Welcome To Ask or Share your Answers For Others

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...