Setting up a new Microsoft MVC.NET site today, I made a possible error in not verifying the initial setup before ripping it into an alternate structure (mostly moving the controllers to a new class library and changing the MVC DLL references to a known version in source control versus what’sGAC), so when the time came to run the site for the first time I didn’t know who to blame for this error:
Compiler Error Message: CS1928: ‘System.Web.Mvc.HtmlHelper’ does not contain a definition for ‘ActionLink’ and the best extension method overload ‘System.Web.Mvc.Ajax.AjaxExtensions.ActionLink( System.Web.Mvc.AjaxHelper, string, string, System.Web.Mvc.Ajax.AjaxOptions)’ has some invalid arguments
The resolution, as found here, was to add:
<add namespace=”System.Web.Mvc.Html”/>
to the system.web/pages/namespaces section of web.config, and all was well.
{ 4 comments… read them below or add one }
Thanks, exactly what i was looking for!
Hi Jay,
I followed the above solution but did not resolve the issue. Still getting the above/same compile time error. Project builds successfully but while running it gets error “Compiler Error Message: CS1031: Type expected”
The code is :-
Please provide the solution.
Thanks
Uday
Hi Jay,
I followed the above solution but did not resolve the issue. Still getting the above/same compile time error. Project builds successfully but while running it gets error “Compiler Error Message: CS1031: Type expected”
The code is :- (hope will get displayed this time.. after removing )
Html.ActionLink(Eval(“Name”).ToString(), new { Action = “Products”, id = Eval(“Id”).ToString() })
Please provide the solution.
Thanks
Uday
Hi Uday, “Type Expected” is a different error, so I suspect you resolved the first error but now have the next of what’s hopefully a short chain of additional issues…
The method signature you’re using for Html.ActionLink looks really old and I don’t think it’s supported in later versions – what version of ASP.NET MVC are you using? Without looking into your data binding code, would something like this work better?
Html.ActionLink(Eval(“Name”).ToString(), "Products", new { id = Eval(“Id”).ToString() })