I have an ASP.net MVC application that has been in Production for a while. I would like to add a new Admin section to the application which I wanted to do by creating a new Area. I'm just curious what sorts of things I might need to be aware of when adding this new area.
Specifically:
Area allows us to partition the large application into smaller units where each unit contains a separate MVC folder structure, same as the default MVC folder structure. For example, a large enterprise application may have different modules like admin, finance, HR, marketing, etc.
The Model-View-Controller (MVC) architectural pattern separates an application into three main components: the model, the view, and the controller.
Step 1: Right-click on the Controller in your Article area to add a controller. Step 2: Select "MVC 5 Empty Controller". Step 3: Enter the name as "ArticleController" . Step 4: Similarly add the controller for "News".
One thing to be careful of is naming collisions - if you have 2 controllers with the same name but in different areas you need to add namespaces, as described here: http://haacked.com/archive/2010/01/12/ambiguous-controller-names.aspx
To restrict the admin area to a certain group, you could use the Authorize attribute with Roles on the Admin controller(s), as desribed here: ASP.NET MVC 3 - How to restrict areas in an efficient way?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With