ASP.net MVC, calling a view from different Controller
I have an EmployeeController
and 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).
In EmpShifts.aspx, I want to give a link to Create New Shift
. I want to know how to call Create
View of Shifts from EmpShifts.aspx
.
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:
<% 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.
精彩评论