我遇到以下编译错误:Compiler Error Message: CS1929: 'HtmlHelper<IEnumerable<Department>>' does not contain a definition for 'ActionLink' and the best extension method overload 'AjaxExtensions.ActionLink(AjaxHelper, string, string, object, AjaxOptions, object)' requires a receiver of type 'AjaxHelper'
但找不到我想念的东西
下面是我的Index.cshtml文件:
@using HotelBookingApp.Models;
@model IEnumerable<Department>
<div style="font-family:Arial">
@{
ViewBag.Title = "Departments List";
}
<h2>Departments List</h2>
<ul>
@foreach (Department department in @Model)
{
<li>
@Html.ActionLink(department.Name,"Index","Employee",
new { departmentId = department.DeptId }, null)
</li>
}
</ul>
</div>
我已经复制了您的代码,并且看起来它正在运行(新的MVC项目),所以问题必须出在配置中。请检查您的Web.config文件(在Views目录中)是否包含此行(configuration.system.web.webPages.razor.pages.namespaces节点):