k12 MVC dependency injection

innovix solutions asked on June 5, 2019 10:27

Hi All,

Kentico mentioned there is dependency-injection sample as below link.

https://docs.kentico.com/k12/developing-websites/initializing-kentico-services-with-dependency-injection

Currently we are developing MVC widgets and do we need to use dependency injection in our project?

Recent Answers


Dmitry Bastron answered on June 5, 2019 14:57 (last edited on June 5, 2019 14:58)

Hi,

You don't necessarily have to use DI container. For working with Kentico APIs you can still use something like:

var membershipActivityLogger = CMS.Core.Service.Resolve<IMembershipActivityLogger>();

But still, it's a best practice to use DI and I would recommend to use it in the development.

0 votesVote for this answer Mark as a Correct answer

innovix solutions answered on June 7, 2019 03:52

ok. thanks.

Understood. what about the our custom query method/function? We are pulling most of data from kentico cloud from kentico EMS. Thanks.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.