Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Why is some application logic inside mvc controllers? #1362


User avatar
0
eggersa created

I noticed that some of the application "logic" is inside mvc controllers like the ProfileController or FileController. I was now wondering why? My guess is, that those APIs are consumed by 3rd party javascript libraries and therefore must not wrap their results in DTOs.


2 Answer(s)
  • User Avatar
    0
    theedge created

    Could I also suggest that some form of Mediator pattern is considered here to keep the controllers thin? And also to make maintenance upgrades easier?

    A .NET mediator implementation [https://github.com/jbogard/MediatR]) can be found here. I have also asked for this elsewhere in ASP.NET boilerplate [https://github.com/aspnetboilerplate/aspnetboilerplate/issues/837])

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    These controllers has 'web specific' logic like uploading files. That's why we could not implement them as regular controllers. This app logic is specific to web apps. If you will develop am native mobile app, you probably upload files in a different way (for example, sending byte arrays). AccountController is also similar. But, honestly, some of it's logic could be moved to application layer.

    Have a nice day.