Reputation: 2108
My current app structure is as follows:
Controller
UserAdminController
GroupsAdminController
I want to modify it the way that for each administration group I have its own folder. For example:
Controller
UserAdmin
-UserAdminController
GroupAdmin
-GroupAdminController
And in my view I want to point to particular controller's action:
@Html.ActionLink("User Administration", "Index","/UserAdmin/UserAdmin")
@Html.ActionLink("Group Administration", "Index", "/GroupAdmin/GroupAdmin")
How can I do it?
Upvotes: 0
Views: 774
Reputation: 3157
You can do this in many ways, but I suggest reading up and using Areas.
Areas
UserAdmin
Controller
-UserAdminController
GroupAdmin
Controller
-GroupAdminController
Also, ActionLink has many overloads one you can use needs ("text", "action", "controller", route values) as following:
@Html.ActionLink("User Administration", "Index","UserAdmin", new { area="UserAdmin" })
@Html.ActionLink("Group Administration", "Index", "GroupAdmin", new { area="GroupAdmin" })
Another option would be to have one area for Admin and just two controllers. Keep in mind that each controller gets its own folder for the views:
Areas
Admin
Controllers
UserController
GroupController
Views
User
Index.cshtml
Group
Index.cshtml
Then your ActionLinks would be:
@Html.ActionLink("User Administration", "Index","User", new { area="Admin" })
@Html.ActionLink("Group Administration", "Index", "Group", new { area="Admin" })
Links would also be nicer IMHO:
/Admin/User
/Admin/Group
Upvotes: 1