[英]ASP.net MVC, calling a view from different Controller
I have an EmployeeController
and ShiftController
. 我有一个EmployeeController
和ShiftController
。 In the Index
View of EmployeeController
I show EmployeeDetails
with options of Edit
, Delete
and GetShifts
(this gets all the shifts of that employee - EmpShifts.aspx). 在EmployeeController
的Index
视图中,我显示了EmployeeDetails
其中包含Edit
, Delete
和GetShifts
选项(这将获得该员工的所有轮班 - EmpShifts.aspx)。 In EmpShifts.aspx, I want to give a link to Create New Shift
. 在EmpShifts.aspx中,我想提供Create New Shift
的链接。 I want to know how to call Create
View of Shifts from EmpShifts.aspx
. 我想知道如何从EmpShifts.aspx
调用Create
View of Shifts。
Am I having the wrong design structure. 我的设计结构是否错误。 Suggestions on that are welcome. 欢迎提出建议。
When generating links you can specify the action and controller they are pointing to: 生成链接时,您可以指定它们指向的操作和控制器:
<%= Html.ActionLink("Create new shift", "create", "shift") %>
Same for HTML forms allowing you to POST: 对于允许您POST的HTML表单也是如此:
<% using (Html.BeginForm("create", "shift")) <% { %>
...
<% } %>
Your design is correct. 你的设计是对的。 It is perfectly normal for having links/forms in some view pointing to other controller actions. 在某些视图中指向其他控制器操作的链接/表单是完全正常的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.