I have created a component to replace ApplicationOnStart but i'm a little puzzled about what to so with the other events in ApplicationEventHandler ie: ApplicationBeginRequest, Session_Start and OnApplicationError (that i'm overriding in V7)
Should I keep global.asax for that or add some event listeners in a component?
Probably something like:
public class ApplicationComposer : ComponentComposer<ApplicationComponent>, IUserComposer
{
public override void Compose(Composition composition)
{
composition.Register<IErrorLogService, ErrorLogService>(Lifetime.Scope);
base.Compose(composition);
}
}
public class ApplicationComponent : IComponent
{
private readonly IErrorLogService _errorLogService;
public ApplicationComponent(IErrorLogService errorLogService)
{
_errorLogService = errorLogService;
}
public void Initialize()
{
//How do I get the ApplicationEventHandler in Umbraco???
Umbraco.Core.Application.BeginRequest += Application_BeginRequest;
Umbraco.Core.Session.Start += Session_Start;
Umbraco.Core.OnApplicationError += OnApplicationError;
//code that originally was in Application_OnStart here
//...
}
public void Terminate()
{
}
}
private void Application_BeginRequest(Object source, EventArgs e)
{
}
private void Session_Start(object sender, EventArgs e)
{
}
private override void OnApplicationError(object sender, EventArgs e)
{
base.OnApplicationError(sender, e);
}
I hope it makes sense and that somebody can help
Thanks
Sorry for my late response.
I implemented too many things without being able to compile and suddenly i just couldn't find my way in all the errors...
I had to start over and manually created all data and document types so now i have a working copy of U8 ;-)
Anyway this worked - at least for BeginRequest and Error.
Still looking for at way to catch the Session_Start event.
Using Global.asax and/or Composers in U8
Hi
I'm converting from U7 V7.15.4 to U8 V8.10.0
I have created a component to replace ApplicationOnStart but i'm a little puzzled about what to so with the other events in ApplicationEventHandler ie: ApplicationBeginRequest, Session_Start and OnApplicationError (that i'm overriding in V7)
Should I keep global.asax for that or add some event listeners in a component? Probably something like:
I hope it makes sense and that somebody can help Thanks
Hi Rasmus
My hunch here is you could handle the UmbracoApplicationBase ApplicationInit event
see this approach in the core:
https://github.com/umbraco/Umbraco-CMS/blob/f288a6334277ef1c3b439c16d94b5ed7df36fb54/src/Umbraco.Web/Logging/WebProfilerComponent.cs#L9
This event would give you access to the underlying HttpApplication app, from which I reckon you could bind to the Begin Request?
regards
Marc
Hi Marc
Sorry for my late response. I implemented too many things without being able to compile and suddenly i just couldn't find my way in all the errors... I had to start over and manually created all data and document types so now i have a working copy of U8 ;-)
Anyway this worked - at least for BeginRequest and Error. Still looking for at way to catch the Session_Start event.
Thanks
I managed to hook up on the Session_Start event also.
https://www.goatly.net/post/hooking-into-session-start-events-in-an-http-module/
Everything is great.
Thanks again Marc :)
is working on a reply...