forked from NLog/NLog.Web
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNLogHttpModule.cs
More file actions
56 lines (50 loc) · 1.45 KB
/
Copy pathNLogHttpModule.cs
File metadata and controls
56 lines (50 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Web;
namespace NLog.Web
{
/// <summary>
/// ASP.NET HttpModule that enables NLog to hook BeginRequest and EndRequest events easily.
/// </summary>
public class NLogHttpModule : IHttpModule
{
/// <summary>
/// Event to be raised at the end of each HTTP Request.
/// </summary>
public static event EventHandler EndRequest;
/// <summary>
/// Event to be raised at the beginning of each HTTP Request.
/// </summary>
public static event EventHandler BeginRequest;
/// <summary>
/// Initializes the HttpModule.
/// </summary>
/// <param name="application">
/// ASP.NET application.
/// </param>
public void Init(HttpApplication application)
{
application.BeginRequest += BeginRequestHandler;
application.EndRequest += EndRequestHandler;
}
/// <summary>
/// Disposes the module.
/// </summary>
public void Dispose()
{
}
private void BeginRequestHandler(object sender, EventArgs args)
{
if (BeginRequest != null)
{
BeginRequest(sender, args);
}
}
private void EndRequestHandler(object sender, EventArgs args)
{
if (EndRequest != null)
{
EndRequest(sender, args);
}
}
}
}