Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 链接到视图中的其他控制器_C#_Asp.net Mvc_Actionlink - Fatal编程技术网

C# 链接到视图中的其他控制器

C# 链接到视图中的其他控制器,c#,asp.net-mvc,actionlink,C#,Asp.net Mvc,Actionlink,我正在用C#编写一个MVC web应用程序 如果操作不在加载视图的控制器中,如何从视图调用控制器上的操作 @Html.ActionLink("Edit", "Edit", new { id=item.BookID }) | @Html.ActionLink("Details", "Details", new { id=item.BookID }) | @Html.ActionLink("Add Comment","Create", "CommentController", new { booki

我正在用C#编写一个MVC web应用程序

如果操作不在加载视图的控制器中,如何从视图调用控制器上的操作

@Html.ActionLink("Edit", "Edit", new { id=item.BookID }) |
@Html.ActionLink("Details", "Details", new { id=item.BookID }) |
@Html.ActionLink("Add Comment","Create", "CommentController", new { bookid=item.BookID }) |
@Html.ActionLink("Delete", "Delete", new { id=item.BookID })
上述代码是从书本控制器加载的。我想在CommentController中调用“Create”操作(参见上面代码的第3行)

当我单击上述代码时,以下页面链接到: serveraddress/Book/Create?长度=17

我正在尝试链接到:
serveraddress/Comment/Create?Length=17

问题在于您使用了错误的重载。替换

@Html.ActionLink("Add Comment","Create", "CommentController", new { bookid=item.BookID })

@Html.ActionLink("Add Comment","Create", "CommentController", new { bookid=item.BookID }, null)
我只在参数列表的末尾添加了null