ASP.NET MVC Structural design problem -
I'm new to ASP.NET MVC and I'm facing some structural design problems.
I can not determine how to setup.
I want the following:
http: // website home> controller action = pointer public: http: // website / {controller}> section controller action = index http: // Website / Products / ID> Product Controller Action = Description http: // website / Products / Category / ID> Product Controller Action = ListByCatId http: // website / products / categories /> ProductsController action =========== ======================= Controller Action = Index ProductCent Roller Action = / Pre> The default map route to most parts right:
path. MapRoute ("default", "{administrator} / {action} / {id}", _ When I start to enter 'Category' instead of product ID {.controller = "home", .action = "index" , .id = ""}}
... Do I have to type 'hardcode' root URL, such as "products / category / {id} "?
For administrator part:
I want to keep all the administrators related to the admin section of the website: /Controllers/Admin/XxxController.vb. Place is possible and they Can the same name be given in the public section? Eq
- Website.Public Parts for Controller Class and
- Website.Admin.ProductsController for Administration section? How should I setup this?
How can I do this?
Routes map {{.id = @ "\ d"} "with new {{controller =" product ", .action =" description ", .id =" "}," new product "{" product deletate "," product / {id} ", _ + "} ) / // is obligation, so this route will not catch the names of any category // under url root With MapRoute ("ProductList", "Products / category / {id}", _New {.controller = "Product", .action = "ListByCatId", .id = "}}} Margaret (" Category "," New {.controller = "product", .action = "ListCategories", .id = ""}} with the Products / Categories / {ID} "_, for the above path, list it on the transaction action // Come and take a null of integer as a parameter in that action. // If there is a value in the ID parameter, then // return details categories (ID) // List the other categories. {{.controller = "home", .action = "index", .id = ""}} with the new "te" ("default", "{controller} / {action} / {id}", _ new To keep two controllers with the same name, yes, you can do it with different namespaces and specify them in the mapRoute method. There is a surcharge in which string [] namespace . Just make sure that you specify the namespace for the controllers with the same name during the writing.
Comments
Post a Comment