【问题标题】:calling different Action Method from another Controller从另一个控制器调用不同的动作方法
【发布时间】:2016-04-07 06:08:30
【问题描述】:

我有一个默认控制器 HomeController.cs,其名称为 ActionLink。我有第二个控制器 StudentController.cs 有几个 ActionMethods。我试图从 Home 控制器的视图中调用 Student 控制器的 GetStudent ActionMethod,但出现以下错误:

“/”应用程序中的服务器错误。找不到资源。

Home Controllers 查看我使用 HTML Helper ActionLink 导航的代码

<p>@Html.ActionLink("Get Student Info", "Main", "Student")</p>

【问题讨论】:

  • @Html.ActionLink("Get Student Info", "GetStudent", "Student")
  • 酷!你可以发布答案以便我标记它吗?

标签: asp.net-mvc-4 navigation html-helper html.actionlink


【解决方案1】:

如果StudentController的方法被命名为GetStudent,那么它需要是

@Html.ActionLink("Get Student Info", "GetStudent", "Student")

第二个参数是你调用的方法的名称。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-23
    • 2011-08-11
    相关资源
    最近更新 更多