Creating subfolders in a controller without scopes

I am developing an MVC 3 web application and I want to create something like this:

/Controller
      /Blog
         BogController.cs
         ViewsController.cs
         ArticlesController.cs
      /Customers
         SalesController.cs
         ProductsController.cs          
      HomeController.cs
/Views
     /Blog
        Index.aspx
        Summary.aspx
        /Views
           Index.aspx
           Admin.aspx
           Show.aspx
       /Articles
          Show.aspx
          Admin.aspx
    /Customers
       /Sales
          Index.aspx
          Totals.aspx
       /Products
          Index.aspx
          Promotions.aspx
     /Home
       Index.aspx

      

Create subfolders in the controller

But in the solution that they answer this guy, for MVC 2 and in MVC 3, the MapAreas property doesn't come out (or at least it doesn't seem to me)

So what can I do to create a structure like / Admin / Users / EditUser? id = 2, for example?

If I need to create a route rule, you can write me an example on how to do it.

+3


source to share


2 answers


Routing rules are definitely the way to go. To create such a structure as you mentioned, write your route rule like this:

routes.MapRoute(
    "user_routing",
    "Admin/{controller}/{action}?id={id}",
    new { }
);

      



Then create a controller named UsersController and an action with ID as a parameter:

public ActionResult EditUser(string id) {
    ...
}

      

+3


source


Consider using the MVC3 Scope . You can create an Admin area for it.



+10


source







All Articles