Take the community feedback survey now.
AI OnAI Off
Take the community feedback survey now.
Don't know if this solves you problem, but you should remove your events aswell and move your _pageEventAttached into the if-statement.
if (!_pageEventAttached)
{
PageBase.PageSetup += new PageSetupEventHandler(PageSetup);
_pageEventAttached = true;
}
public void Uninitialize(EPiServer.Framework.Initialization.InitializationEngine context)
{
PageBase.PageSetup -= new PageSetupEventHandler(PageSetup);
_pageEventAttached = false;
}
Otherwise I guees you could end up with multiple events.
My initialization module behaves a bit strangely, it seems to initialize at random. Sometimes it's run 4, 5, 6 times in a row, and then it just won't initialize.
This happens in the development environment as well as in stage. I've set break points in the Initialize method and they're sometimes not hit.
What can be wrong? Here's the code:
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Text; using System.Web; using EPiServer; using EPiServer.Core; using EPiServer.Framework; using IAR.Base.PageTypeDefinitions; using PageTypeBuilder; namespace MyProject.Base.EventHandlers { [InitializableModule] [ModuleDependency(typeof(PageTypeBuilder.Initializer))] public class RedirectHandler : IInitializableModule { private bool _pageEventAttached; /// <summary> /// Attaches event handlers /// </summary> /// <param name="context">The context.</param> public void Initialize(EPiServer.Framework.Initialization.InitializationEngine context) { if (!_pageEventAttached) { PageBase.PageSetup += new PageSetupEventHandler(PageSetup); } _pageEventAttached = true; } private void PageSetup(PageBase sender, PageSetupEventArgs e) { sender.Init += new EventHandler(My_Method); } private void My_Method(object sender, EventArgs e) { // ... } /// <summary> /// Preload is not required for this module /// </summary> /// <param name="parameters">The parameters.</param> public void Preload(string[] parameters) { throw new NotImplementedException(); } /// <summary> /// Uninitializes the specified context. /// </summary> /// <param name="context">The context.</param> public void Uninitialize(EPiServer.Framework.Initialization.InitializationEngine context) { _pageEventAttached = false; } } }
http://world.episerver.com/Modules/Forum/Pages/Forum.aspx?id=46471&epslanguage=en