0

下面是我在 ASP MVC3 视图中使用的操作链接。我需要控制器中的一个方法并发送两个变量。这些变量用作控制器方法试图从中提取信息的 SQL 表上的复合键。

该链接似乎由 正确呈现@Html.ActionLink,但是我收到此错误:

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /BankListMasterController/AgentEdit/11

这是动作链接

@Html.ActionLink("Edit Agent", "AgentEdit", "BankListMasterController",
                                            new { agentId = int.Parse(item.AgentId), id = item.ID }, null)

这是控制器方法

    public ViewResult AgentEdit(int id, int agentId)
    {
        string compare = agentId.ToString();

        BankListAgentId agent = (from c in db.BankListAgentId
                                 where c.ID == id &&
                                       c.AgentId.Equals(compare)
                                 select c).Single();

        return View("AgentEdit", agent);
    }

这是在原始视图中呈现的 URL

http://localhost:2574/BankListMasterController/AgentEdit/11?agentId=5309721

我还在方法的第一行放置了一个断点,并且在调试时它永远不会被绊倒。

4

1 回答 1

1

您不需要在第三个参数中包含“控制器”。

尝试:

@Html.ActionLink("Edit Agent", "AgentEdit", "BankListMaster", new { agentId = int.Parse(item.AgentId), id = item.ID }, null)
于 2013-04-04T23:51:50.757 回答