【发布时间】:2012-10-13 15:49:28
【问题描述】:
假设我正在开发汽车门户网站。要搜索新车,用户需要提供以下信息:
- 品牌
- 型号
- 模型版本
- 燃料类型
- 预算
业务规则:
- 如果用户只选择品牌:显示品牌列表页面以及所选品牌的所有型号
- 如果用户选择品牌和型号:显示型号列表页面
- 如果用户选择品牌 + 型号 + 型号版本:显示型号版本详细信息页面。
- 如果用户选择燃料类型或预算:显示品牌列表页面。
现在我有两种方法来定义控制器和动作。
方法一:一个Controller类有多个动作方法
Controller Class : CarSearchmanager
with following are Action Methods:
- SearchNewCar(int Barnd,int Model.......)
Depending on user selection this method will redirect control to following
action method:
- BrandListing(int BrandID......)
- ModelListing(int BrandID,intModelID.....)
- ModelVersionDetails((int BrandID,intModelID,int ModelVersionID....)
方法二:多控制器类
Controller Class : CarSearchmanager
Following are Action Methods:
- SearchNewCar(int Barnd,int Model.......)
Depending on user selection this method will redirect control to following
controller action method:
Then I will have separate controller class and action method for each of the pages like
bellow:
- BrandListing
- ModelListing
- ModelVersionDetails
我很困惑如何组织控制器类和动作方法。是否有任何最佳实践类型的文档?请给我推荐一个。
【问题讨论】:
标签: asp.net-mvc controller asp.net-mvc-4 actionmethod code-standards