私はASP.NET MVCを初めて使用しています。構造的な問題に直面しています。ASP.NET MVC構造設計の問題
ルーティングの設定方法を理解できません。
私は次のことをしたい:
http://website/ > HomeController Action=Index Public: http://website/{controller} > SectionController Action=Index http://website/products/id > ProductsController Action=Details http://website/products/category/id > ProductsController Action=ListByCatId http://website/products/categories/ > ProductsController Action=ListCategories http://website/products/categories/id > ProductsController Action=DetailsCategories Admin: http://website/admin/ > AdminController Action=Index http://website/admin/{controller} > SectionController Action=Index
デフォルトmapRouteは、部品のほとんどの罰金です:
routes.MapRoute("Default", "{controller}/{action}/{id}", _
New With {.controller = "Home", .action = "Index", .id = ""})
私は「カテゴリ」の代わりに、製品のIDの問題を入れて起動すると、開始...
私は 'route'rls、'ハードコードする必要があります"products/category/{id}"?管理部分について
:/Controllers/Admin/XxxController.vb:
私は中のWebサイトの管理セクションに属するすべてのコントローラを入れたいと思います。それらを名前空間にすることが可能であり、それらを公開セクションと同じ名前にすることができますか? e.q.
- Website.ProductsController public classのクラスと
- Admin.web.Admin.ProductsController for Adminセクション?これをどのようにセットアップすればよいですか?
*エリア*(MVC 2で新機能)がこれを手伝ってくれるかもしれません。それらは、あなたのサイトの異なるエリア間をきれいに分けることができます。エリアでは、ルーティングやコントローラなどが定義されます。 – bzlm