Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8075869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:08:09+00:00 2026-06-05T15:08:09+00:00

I have question about parsing in Html helper : I have sth like: @foreach

  • 0

I have question about parsing in Html helper :

I have sth like:

@foreach (var item in ViewBag.News)
{
    @Html.ActionLink(item.gdt_title, "News", "News", new { lang = ViewBag.Lang, page = ViewBag.CurrentPage, id = item.gdt_id }, null)
}

so then I have an error:

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

I solve it with manualy parse first parametr to string:

@foreach (var item in ViewBag.News)
{
    @Html.ActionLink((String)item.gdt_title, "News", "News", new { lang = ViewBag.Lang, page = ViewBag.CurrentPage, id = item.gdt_id }, null)
}

But I don’t know why it happen.

Can somebody explain it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:08:13+00:00Added an answer on June 5, 2026 at 3:08 pm

    Using ViewBag/ViewData is bad practice.

    You are using dynamic model, and item.gdt_title is dynamic. As the exception says,

    Extension methods cannot be dynamically dispatched

    You should be using strongly typed view models. Something like this

    public class NewsViewModel
    {
        public string Lang { get; set; }
        public int CurrentPage { get; set; }
        public List<NewsItem> News { get; set; }
    }
    
    public class NewsItem
    {
         public string gdt_id { get; set; }
         public string gdt_title { get; set; }
    }
    

    controller

    public ActionResult News()
    {
         NewsViewModel news = new NewsViewModel();
         news.News = LoadNews();
    
         return View(news);
    }
    

    view

    @model NewsViewModel
    
    @foreach (var item in Model.News)
    {
        @Html.ActionLink(item.gdt_title, "News", "News", new { lang = Model.Lang, page = Model.CurrentPage, id = item.gdt_id }, null)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about XML parsing. I was experimenting with a sample program
There is no day on SO that passes without a question about parsing (X)HTML
The question is not really about parsing the HTML, but rather parsing the HTML
I have a basic question about parsing expression trees. Is there a difference between
i have one question. I ready many pages about best thereading like this http://www.albahari.com/threading/part4.aspx
I have question about parsing a specific json string. I didn't find anything which
I have question about normalization. Suppose I have an applications dealing with songs. First
I have question about interpreting strings as packed binary data in C++. In python,
i have question about YAJLiOS parser... I have next json data : {{ body
I have a question about whether or not a specific way of applying of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.