Html.ActionLink cannot be dynamically dispatched

C#asp.net MvcHtml Helper

C# Problem Overview


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.

C# Solutions


Solution 1 - C#

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAndreas ErikssonView Question on Stackoverflow
Solution 1 - C#MikebView Answer on Stackoverflow