为什么 IContentEvents.LoadedContent 事件会针对一个页面多次触发?

Why is the IContentEvents.LoadedContent event fired multiple times for a page?

我已经为 LoadedContent 事件添加了事件处理程序。我有点惊讶该事件似乎在一次加载期间为一个页面触发了多次。为什么会这样?

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();
    ServiceLocator.Current.GetInstance<IContentEvents>().LoadedContent += this.EPiServerApplication_LoadedContent;           
}

编辑

我正在使用 EPiserver 8。

对于 "a singe load" 我的意思是从 DOPE 模式到编辑模式的子页面,但没有子页面。上次我计算该页面的事件触发了 17 次。

每次 Get/TryGet 调用 IContentLoader(或 IContentRepository)时都会触发 LoadedContent 事件。无论数据是从缓存还是从数据库加载,都会发生这种情况。

由于这些 API 被许多单独的代码分支使用,尤其是在编辑模式下,正如您所发现的,此事件将被多次触发。通常这应该不是您需要担心的任何事情,除非您在事件处理程序中执行资源密集型操作。