/// <summary> /// Will raise the event on the current thread synchronously. /// i.e. it will wait until all event handlers have processed the event. /// </summary> /// <param name="args">The state to be passed to the event.</param> private void RaiseOnLogUrlEvent(LogUrlEventArgs args) { // Make a temporary copy of the event to avoid possibility of // a race condition if the last subscriber unsubscribes // immediately after the null check and before the event is raised. LogUrlEventHandler eventHandler; if (!Monitor.TryEnter(logUrlEventLock, lockTimeout)) { throw new ApplicationException("Timeout waiting for lock - RaiseOnLogUrlEvent"); } try { eventHandler = logUrlEvent; } finally { Monitor.Exit(logUrlEventLock); } OnLogUrlEvent(args); if (eventHandler != null) { eventHandler(this, args); } }
protected static void OnLogUrlEvent(object sender, LogUrlEventArgs args) { //Usually log request to database. Information to include is User, Url, Date/Time etc var request = args.HttpApplication.Request; var referrer = string.Empty; if (request.UrlReferrer != null) { referrer = request.UrlReferrer.PathAndQuery; } var url = request.Path; var querystring = request.QueryString; var userAgent = request.UserAgent; }
/// <summary> /// Raise log url event /// </summary> /// <param name="httpApplication">The httpApplication the request was raised on.</param> /// <param name="expression">The expression that matched the url.</param> internal void RaiseLogUrlEvent(HttpApplication httpApplication, string expression) { var beforeLogUrlEventArgs = new BeforeLogUrlEventArgs(httpApplication, expression); RaiseOnBeforeLogUrlEvent(beforeLogUrlEventArgs); if (beforeLogUrlEventArgs.Cancel) { return; } var logUrlEventArgs = new LogUrlEventArgs(httpApplication, expression); RaiseOnLogUrlEvent(logUrlEventArgs); var afterLogUrlEventArgs = new AfterLogUrlEventArgs(httpApplication, expression); RaiseOnAfterLogUrlEvent(afterLogUrlEventArgs); }
/// <summary> /// Will raise the event on the calling thread asynchronously. /// i.e. it will immediatly continue processing even though event /// handlers have not processed the event yet. /// </summary> /// <param name="args">The state to be passed to the event.</param> private void RaiseAsynchronousOnLogUrlEvent(LogUrlEventArgs args) { asyncOperation.Post(new SendOrPostCallback(AsynchronousOnLogUrlEventRaised), args); }
/// <summary> /// Will raise the event on the calling thread synchronously. /// i.e. it will wait until all event handlers have processed the event. /// </summary> /// <param name="args">The state to be passed to the event.</param> private void RaiseCrossThreadOnLogUrlEvent(LogUrlEventArgs args) { asyncOperation.SynchronizationContext.Send(new SendOrPostCallback(AsynchronousOnLogUrlEventRaised), args); }
/// <summary> /// Template method to add default behaviour for the event /// </summary> private void OnLogUrlEvent(LogUrlEventArgs e) { // TODO: Implement default behaviour of OnLogUrlEvent }
/// <summary> /// Raise log url event /// </summary> /// <param name="httpApplication">The httpApplication the request was raised on.</param> /// <param name="expression">The expression that matched the url.</param> private void RaiseLogUrlEvent(HttpApplication httpApplication, string expression) { var beforeLogUrlEventArgs = new BeforeLogUrlEventArgs(httpApplication, expression); RaiseOnBeforeLogUrlEvent(beforeLogUrlEventArgs); if (beforeLogUrlEventArgs.Cancel) return; var logUrlEventArgs = new LogUrlEventArgs(httpApplication, expression); RaiseOnLogUrlEvent(logUrlEventArgs); var afterLogUrlEventArgs = new AfterLogUrlEventArgs(httpApplication, expression); RaiseOnAfterLogUrlEvent(afterLogUrlEventArgs); }
/// <summary> /// Will raise the event on the current thread synchronously. /// i.e. it will wait until all event handlers have processed the event. /// </summary> /// <param name="args">The state to be passed to the event.</param> private void RaiseOnLogUrlEvent(LogUrlEventArgs args) { // Make a temporary copy of the event to avoid possibility of // a race condition if the last subscriber unsubscribes // immediately after the null check and before the event is raised. LogUrlEventHandler eventHandler; if (!Monitor.TryEnter(logUrlEventLock, _lockTimeout)) { throw new ApplicationException("Timeout waiting for lock - RaiseOnLogUrlEvent"); } try { eventHandler = logUrlEvent; } finally { Monitor.Exit(logUrlEventLock); } OnLogUrlEvent(args); if (eventHandler != null) { eventHandler(this, args); } }
/// <summary> /// Will raise the event on the calling thread asynchronously. /// i.e. it will immediatly continue processing even though event /// handlers have not processed the event yet. /// </summary> /// <param name="args">The state to be passed to the event.</param> private void RaiseAsynchronousOnLogUrlEvent(LogUrlEventArgs args) { _asyncOperation.Post(new SendOrPostCallback(AsynchronousOnLogUrlEventRaised), args); }
/// <summary> /// Will raise the event on the calling thread synchronously. /// i.e. it will wait until all event handlers have processed the event. /// </summary> /// <param name="args">The state to be passed to the event.</param> private void RaiseCrossThreadOnLogUrlEvent(LogUrlEventArgs args) { _asyncOperation.SynchronizationContext.Send(new SendOrPostCallback(AsynchronousOnLogUrlEventRaised), args); }
/// <summary> /// Template method to add default behaviour for the event /// </summary> private void OnLogUrlEvent(LogUrlEventArgs e) { // TODO: Implement default behaviour of OnLogUrlEvent }