我正在开发一个MVC 3 Web应用程序,我想创建这样的东西: /Controller /Blog BogController.cs ViewsController.cs ArticlesController.cs /Customers SalesController.cs ProductsController.cs HomeController.cs/Views /Blog Index.as
/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 sub folders in the controller
但是他们回答这个人的解决方案是针对MVC 2和MVC 3中的MapAreas属性不会退出(或者至少它不会出现在我看来)
那么我可以做些什么来构建像/ Admin / Users / EditUser这样的结构?例如id = 2?
如果我需要创建一个路由规则,你能不能给我写一个如何做的例子.
路由规则绝对是可行的方法.要创建一个像你提到的结构,写下这样的路由规则:routes.MapRoute(
"user_routing",
"Admin/{controller}/{action}?id={id}",
new { }
);
然后创建一个名为UsersController的控制器,以及一个id为参数的动作:
public ActionResult EditUser(string id) {
...
}
