views:

212

answers:

1

I am little bit confuse with Asp.net MVC Area.

When we talk about WebForms we say, for Administrative tasks, you must have an Admin folder to separate the admin task.

In MVC how i will treat my Admin tasks?

I will go for Admin Area or Admin Controllers,

Because if i will write controller for Admin tasks, each and every task will be written in one controller (AdminController) or if i will write Area -> Controller, means i will need to write at-least two controllers for each feature.

Second if we breaks the application in Areas (as modules) how i will manage Admin task for each Area.

A: 

Hey,

Yes, those are your options; you can use one admin controller, or separate admin action methods in different controllers broken or take advantage of MVC 2 areas feature (if possible depending on requirements).

How are your administrative tasks laid out? For instance, if you have a customers and products section, do you have administrative features with each of these areas, or do you have admin features for the site only, or something like that?

Brian
i am developing a Library Portal, in which i have books, Media Library ( Images, Audio, Video etc), Forum etcI am planing to create Media Library as an Area, Forum as an other Area and so on..All these features will have Administrative task.Now, i have two choice to do this job...1, Create a saparate Admin Area which have separat Controller as MediaController, ForumController etcFor this route will be "http://myweb.com/Admin/{Controller}/{Task}" (a user friendly address).continue....
Cruiser KID
2, Create an AdminController in all those Areas. in which i will have "http://myweb.com/{Area}/AdminColtroller/{Task}", which is not user friendly for meThe corn of 1st choice, is each Area will be depending on Admin Area, which is not a good idea but it is provideing good route.The corn of 2nd choice, although i can copy the Area to other project for reuse but the route will not user friendly.Solution as i think, go for choice 2, Create AdminController in each Area, and create routes as choice 1 then map it to AdminController :) am i right
Cruiser KID
Yes, you are on the right track if I understand correctly. Other options: Each area could have an Admin view/action method within those controllers, so MediaController.Admin action method for the admin area, so you don't have to create a separate controller (not sure that's better, just another option). Or have a link in each module for admin, but use RedirectToActionResult, which redirects to one central admin module, so it looks like each area has an admin section, but you can redirect to an action outside the area/controller...
Brian