I have a class in which I need to create an instance of ContentService. Following on from following on from https://our.umbraco.org/Documentation/Reference/Common-Pitfalls/ is it advisable to create the ApplicationContext.Current.Services.ContentService as a static instance. I am not getting something right I believe.
I found this in code I inherited. I have always stuck to using the Services property in SurfaceControllers or invoking it off ApplicationContext. I read Shannon's post and thought the line of code would lead to miserable issues in the long run but just wanted some community opinion. Many thanks Alex
Umbraco Performance
I have a class in which I need to create an instance of ContentService. Following on from following on from https://our.umbraco.org/Documentation/Reference/Common-Pitfalls/ is it advisable to create the ApplicationContext.Current.Services.ContentService as a static instance. I am not getting something right I believe.
Poornima
Hi Poornima,
Do not create static instances of ContentService.
Use created one - ApplicationContext.Current.Services.ContentService
Can you provide code of your classes, we can look at and find something together.
Thanks,
Alex
I found this in code I inherited. I have always stuck to using the Services property in SurfaceControllers or invoking it off ApplicationContext. I read Shannon's post and thought the line of code would lead to miserable issues in the long run but just wanted some community opinion. Many thanks Alex
Poornima
is working on a reply...