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

后端 未结 7 1202
-上瘾入骨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:19

    I would not want to have 50 controllers. Right now I have 16 in my application and that feels ok. If you have 50 controllers you will also have 50 toplevel folders for views. It will be hard to find the view and controller you need to work on. As others mentioned actions are typically short and its not that bad to have a couple of them in your controller.

    I tried to have 1 controller by system part. I define a system part by taking my database schema and drawing a line around tables that belong together.

提交回复
热议问题