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

后端 未结 7 1317
-上瘾入骨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条回答
  •  Happy的楠姐
    2021-01-30 02:14

    In my humble opinion, if you are keeping the code in your controllers down then it doesn't really matter.

    Most of your code would be happening in a business layer somewhere right? If that's the case then all you are really doing in your controller is returning data to the view. As it should be.

    Not really sure if I'm a fan of seperating the controllers into subtypes. Whilst you should maintain seperation of concerns I think subtypes is going a little too far.

    You could take a look at this post to see if it helps. Same View Different Paths

    That may be a better solution than using a subtype approach that you suggested.

提交回复
热议问题