私は ASP.NET MVC を初めて使用し、構造設計の問題に直面しています。
ルーティングの設定方法がわかりません。
私は次のものが欲しい:
http://website/ > HomeController Action=Index 公衆: 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 アクション=ListCategories http://website/products/categories/id > ProductsController Action=DetailsCategories 管理者: 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 の代わりに「カテゴリ」を入力し始めると、問題が発生します...
「products/category/{id}」などの routeUrl を「ハードコード」する必要がありますか?
管理者の場合:
Web サイトの管理者セクションに属するすべてのコントローラーを /Controllers/Admin/XxxController.vb に配置したいと思います。それらに名前空間を付けて、公開セクションと同じ名前にすることは可能ですか? eq
- パブリック パーツの Website.ProductsController クラスと
- 管理セクションの Website.Admin.ProductsController ? これをどのようにセットアップすればよいですか?