This is a slightly subjective question, as there really is no βrightβ answer. In fact, you need to consider a few points.
- How safe is it to follow a simple route, and does the dependency allow the controller instance?
- Will this logic be used elsewhere?
- Are these two issues separate applications?
In essence, if the API and the MVC application have a difference problem, then they should be properly separated, and the MVC application should call the WebAPI application using the HttpClient. This can significantly reduce attacks and individual applications.
If MVC and WebAPI display the same information at the same time, and security / separation of problems is not a problem, then it is enough to enable controller dependency management.
If logic does not share the problem of problems, and it will be used in several places, then factoring it into common components is likely to be your best bet.
Shooting from the hip sounds like a small application that can benefit from dependencies that allow the controller in the near future. As the application grows (or if it is already planned), splitting the logic into the correct SOA format will be useful.
tl; dr - SO really cannot answer this question without knowing what such an application will do. Be pragmatic.
Dustin venegas
source share