using System; using System.Web; using NLog.Web.Targets.Wrappers; namespace NLog.Web { /// /// ASP.NET HttpModule that enables NLog to hook BeginRequest and EndRequest events easily. /// /// Documentation on NLog Wiki [Obsolete("Replaced by NLogBufferingTargetWrapperModule for AspNetBufferingWrapper support. Marked obsolete with NLog 6.0")] public class NLogHttpModule : IHttpModule { /// /// Event to be raised at the end of each HTTP Request. /// public static event EventHandler? EndRequest; /// /// Event to be raised at the beginning of each HTTP Request. /// public static event EventHandler? BeginRequest; /// /// Notify the wrapper target that the correct IHttpModule is installed /// public NLogHttpModule() { AspNetBufferingTargetWrapper.MiddlewareInstalled = true; } /// /// Initializes the HttpModule. /// /// /// ASP.NET application. /// public void Init(HttpApplication application) { application.BeginRequest += BeginRequestHandler; application.EndRequest += EndRequestHandler; } /// /// Disposes the module. /// public void Dispose() { } private void BeginRequestHandler(object sender, EventArgs args) { BeginRequest?.Invoke(sender, args); } private void EndRequestHandler(object sender, EventArgs args) { EndRequest?.Invoke(sender, args); } } }