forked from extnet/Ext.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnalyticsModule.cs
More file actions
46 lines (38 loc) · 1.58 KB
/
AnalyticsModule.cs
File metadata and controls
46 lines (38 loc) · 1.58 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
using System;
using System.Globalization;
using System.Web;
using System.Web.Configuration;
using Ext.Net.Utilities;
namespace Ext.Net.Examples
{
public class AnalyticsModule : IHttpModule
{
public void Init(HttpApplication app)
{
app.ReleaseRequestState += RequestFilter;
}
private void RequestFilter(object sender, EventArgs e)
{
if (HttpContext.Current == null || HttpContext.Current.Response == null)
{
return;
}
HttpResponse response = HttpContext.Current.Response;
bool localLog = Convert.ToBoolean(WebConfigurationManager.AppSettings["LocalLogging"]);
if (!RequestManager.IsAjaxRequest && (localLog || HttpContext.Current.Request.Url.Host != "localhost"))
{
object marker = HttpContext.Current.Items[ResourceManager.FilterMarker];
string url = HttpContext.Current.Request.FilePath;
bool isExample = url.StartsWith("/Examples/", true, CultureInfo.InvariantCulture) && url.EndsWith(".aspx");
if (marker != null && (bool)marker && isExample)
{
if (response.ContentType.IsNotEmpty() && response.ContentType.Equals("text/html", StringComparison.InvariantCultureIgnoreCase))
{
response.Filter = new AnalyticsFilter(response.Filter);
}
}
}
}
public void Dispose() { }
}
}