Better to have huge Controllers, or many controllers, in MVC?

后端 未结 7 1201
-上瘾入骨i
-上瘾入骨i 2021-01-30 01:23

We are building a fairly large HR application in ASP.NET MVC, and so far our controllers are becoming quite large. For example, we have an Employee controller, and all employee

7条回答
  •  旧时难觅i
    2021-01-30 02:02

    Why not group them?

    Have a structure like,

    employee/payroll/
        employee/payroll/giveraise
        employee/payroll/manage401k
    
    employee/general/
        employee/general/address
        employee/general/emergencycontact
    

    Now you can have one payroll controller handling payroll related actions and a general controller which handles regular details of an employee.

提交回复
热议问题