Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC3 - add a folder to controllers?

I want to learn is it possible to add additional folder to Controller folder. My reason is pretty simple: I want to divide my project administration and client sides.

Example: I have a controller named Post that has actions Index, Details, Delete, Create, Edit. I want to make one controller as user controller that will consist of Index, Details and another controller as admin controller that will consist of Delte, Create, Edit. Then I will be able to easy distinguish what is what and put admin validation on whole admin class.
Another reason is that I want my url for administrating my site to look like /admin/post/delete, not /post/delete.

So is it possible, and if so then what would be the best way to implement this?

like image 490
Stan Avatar asked May 30 '12 06:05

Stan


2 Answers

Sound like you want to use MVC Areas? http://www.c-sharpcorner.com/UploadFile/b19d5a/areas-in-Asp-Net-mvc3/

like image 81
ltiong_sh Avatar answered Nov 17 '22 11:11

ltiong_sh


It's just a convention on placing controllers in Controllers folder.
Actually MVC finds controller in current loaded assemblies.
You can place them even in other assemblies.
So, fell free to create additional folders inside Controllers

like image 45
Nickmaovich Avatar answered Nov 17 '22 12:11

Nickmaovich