|
|
Hi,
I am trying to integrate n2 cms with an existing asp.net 3.5 website that uses silverlight controls, and after doing so began to get this error:
Event handlers can only be bound to HttpApplication events during IHttpModule initialization.
Also, when attempting to login to edit the site, I was getting an erorr advising that n2.security could not be found.
Hoping you can point me in the right direction!
Thanks,
turpya
|
|
Coordinator
Oct 23, 2008 at 6:11 AM
|
Can you post a stack trace? Is there a way N2.Context.Current is called before the InitializationModule?
Can you take a look in /bin? Does it contain a dll n2.security.dll?
|
|
|
|
Same issue:
Stack Trace:
[InvalidOperationException: Event handlers can only be bound to HttpApplication events during IHttpModule initialization.]
System.Web.HttpApplication.ThrowIfEventBindingDisallowed() +11178275
System.Web.HttpApplication.AddSyncEventHookup(Object key, Delegate handler, RequestNotification notification, Boolean isPostNotification) +30
System.Web.HttpApplication.add_BeginRequest(EventHandler value) +59
N2.Web.RequestLifeCycleHandler.Init(HttpApplication application) +102
N2.Engine.ContentEngine.Attach(HttpApplication application) +48
N2.Context.get_Current() +76
N2.Edit.Web.EditPage.get_SelectedItem() +46
N2.Edit.Default.OnInit(EventArgs e) +100
System.Web.UI.Control.InitRecursive(Control namingContainer) +143
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1477
|
|
Coordinator
Nov 23, 2008 at 9:00 AM
|
Do you have the the n2 http modules
configured? If you use IIS 7 you should look at /configuration/system.webServer/modules, otherwise /configuration/system.web/httpModules.
|
|
|
|
From what you're telling, it looks like you're running on IIS7 with a several nested asp.net applications (possibly "nested" via IIS virtual folders). I've faced the same trouble just today. My brief investigation showed that by default IIS forces
"child" application to inherit "parent"'s web.config. So if you have App1 configured in the root of web server: "/" , and another App2 in some VFolder one level lower: "/MyApp2/", then App2 will unconditionally inherit
App1's web.config with a random strange side-effects. And it doesn't matter that App2 may physically be located apart from App1 -- it only IIS VFolder hierarchy that matters here. You can read about a possible work-around from Rick Strahl [ http://www.west-wind.com/Weblog/posts/10091.aspx
], but this trick still require heavy modifications to a parent web.config. And still the problem with ~/Edit, as you've pointed it out, requires a separate treatment.
|
|
|
|
Did you solve this issue?
I'm running IIS7 and I'm getting "Event handlers can only be bound to HttpApplication events during IHttpModule initialization. "
System.Web.HttpApplication.ThrowIfEventBindingDisallowed()
at System.Web.HttpApplication.AddSyncEventHookup(Object key, Delegate handler, RequestNotification notification, Boolean isPostNotification)
at System.Web.HttpApplication.add_BeginRequest(EventHandler value)
at N2.Web.RequestLifeCycleHandler.Init(HttpApplication application)
at N2.Engine.ContentEngine.Attach(HttpApplication application)
at N2.Context.get_Current()
at N2.Persistence.GenericFind`2.get_StartPage()
at leftmenu.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
and I have this setup
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<add name="n2.initializer" type="N2.Web.InitializerModule, N2" />
<add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated" />
<add name="n2.ajax" path="*.n2.ashx" verb="*" type="N2.Web.AjaxRequestHandler, N2" />
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions,
Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions,
Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
|
|
Coordinator
Jan 18, 2009 at 10:03 PM
|
I'm not sure why, but it would seem the code in InitializerModule isn't executed, or somehow fails. There arn't any different execption the first time the site starts?
|
|
|
|
Think I have fixed it,
problem was SqlExpress wasn't installed on server. Not obvious from error, so will see if can get the error again.
|
|
|
|
It wasn't SqlExpress, didn't think that made any sense.
I was trying to display some of the N2cms contents on the left hand menu outside of N2cms. But N2cms hadn't initiallised at this point. Works fine if you go to the admin pages first then back to start.
Anyway to force initilization on a non N2cms page?
|
|
Coordinator
Jan 19, 2009 at 5:10 PM
|
Can you figure out what exception is thrown during module initialization? Try enabling logging trace. The probable cause is something going wrong during initialization leaving the engine singleton as null. This will lead to it beeing re-created the first
time it's accessed in leftmenu.Page_Load.
|
|
|
|
Hi,
I know this is a rather old thread, but experience the same problem when running on IIS 7. I have moved the configurationsection of modules to <system.webServer> but no luck. I just don't get it, why is this working on IIS 6 but not on IIS 7?
Thanks
|
|
|
|
Normally, the only diff between running n2 on IIS 6 vs 7 is config section where n2initializer module is defined, as you rightly mentioned. Does application fail with YSOD ? If so, please check that the syntax of module registration is correct (it has slightly
changed in IIS 7).
|
|
|
|
Thanx! Problem solved. Well, it works now anyway :o). According to http://help.godaddy.com/article/4162#six there have been som change regarding HttpModules and HttpHandlers in IIS7
as you stated. Anyway, I ran N2 application pool in a classic mode instead of integrated and now it works.
Cheers!
|
|
Coordinator
Oct 14, 2009 at 10:09 PM
Edited Oct 14, 2009 at 10:10 PM
|
Good that it worked in classic mode. It's possible to run in integrated mode using the IIS 7 configuration in the system.webServer section of the templates
web.config.
|
|