HTML helper操作链接

问题描述 投票:0回答:1

我遇到以下编译错误: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>
asp.net model-view-controller html-helper actionlink
1个回答
0
投票

我已经复制了您的代码,并且看起来它正在运行(新的MVC项目),所以问题必须出在配置中。请检查您的Web.config文件(在Views目录中)是否包含此行(configuration.system.web.webPages.razor.pages.namespaces节点):

© www.soinside.com 2019 - 2024. All rights reserved.