In the asp.net mvc application in several controllers, the same code is used. Is it possible to bring these procedures to some common space for all controllers?

  • one
    as an option to create a kind of service layer which will contain common methods / functions, and, if necessary, use them in the required controllers - Bald
  • Is @Bald service layer some kind of class? Where should it be stored? - Sergey Tambovtsy
  • yes, store where it will be convenient for you - Bald
  • @Bald thanks, it looks like what I wanted) - Sergey Tambovtsev
  • one
    @Bald in my opinion, two lines will be enough. - Sergey Tambovtsy

1 answer 1

I would try to put the duplicate functions / methods into the service layer (the class in which the necessary methods / functions will be implemented), which would connect as needed to the necessary controllers and thus get rid of duplication