0

I am not very much familiar with razor view engine. I tried this code.

@for(var item in ViewBag.list)
{
    @foreach (var itemvote in ViewBag.listVote)
    {
        <h1>@Html.ActionLink(@item.Title, "Details", "Report", new { id = item.Id},null)</h1>
    }
}

And it shows the following error:

Compiler Error Message: CS1973: 'System.Web.Mvc.HtmlHelper' 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.

my controller class is ReportController and method is Details to which it will be submitted.

public ActionResult Details(int id = 0)
        {
            Report report = Context.Reports.Find(id);
            if (report == null)
            {
                return HttpNotFound();
            }
            ViewBag.report = report;

            return View();
        }

I googled and found some link like HTML.ActionLink method

but i am still unable to correct it.

Community
  • 1
  • 1
Moshiur Rahman
  • 103
  • 1
  • 9

1 Answers1

0

There are at least 2 problems with your call to actionlink.

First, the first parameter does not require a '@' because you're already using one at the start of the line with @Html.ActionLink.

Secondly, the first parameter should be itemvote.Title not item.Title, as you don't have a variable called item.

That could be part of your problem, because the compiler might not realize that @item.Title is supposed to be a string, and there is a valid signature of ActionLink(string, string, string, Object, Object)

taylonr
  • 10,732
  • 5
  • 37
  • 66