I am trying to read a component when an event system extension is first initialized in an 8.5 instance. So in my event system extension's constructor, I try to get the component from the Administrator session like this:
[TcmExtension("EventHandlerExtension")]
public class Event : TcmExtension
{
public Event()
{
Session session = new Session("Administrator");
Component component = (Component)session.GetObject("tcm:xx-xxxx-xx");
}
}
When I do this, I get a timeout. This might be because the Network Service is not able to create an Administrator session during initialization.
However, when I try to use the Administrator session in an event handler (for example, when a component is saved), I am not seeing the timeout and the component is being retrieved.
public void HandleForComponentSaveInitiated(Component item, SaveEventArgs args, EventPhases phase)
{
Session session = new Session("Administrator");
Component component = (Component)session.GetObject("tcm:xx-xxxx-xx")
}
My questions are:
- What is the best approach to read a Tridion item only once when an event system extension is first initialized?
- Is Core Service the other option? (I know it is not recommended to use Core Service in an event system).
We are trying not to be dependent on DevOps for config updates so we would like to have our config settings stored in a Tridion component and have it read when the event system extension is initialized.