The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TrackPageView.cs 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Web;
  7. using Teknik.Configuration;
  8. using Teknik.Utilities;
  9. using Teknik.Piwik;
  10. using Microsoft.AspNetCore.Mvc.Filters;
  11. using Microsoft.AspNetCore.Http;
  12. using Microsoft.AspNetCore.Http.Extensions;
  13. namespace Teknik.Filters
  14. {
  15. public class TrackPageView : ActionFilterAttribute
  16. {
  17. public TrackPageView()
  18. {
  19. }
  20. public override void OnActionExecuting(ActionExecutingContext filterContext)
  21. {
  22. }
  23. public override void OnActionExecuted(ActionExecutedContext filterContext)
  24. {
  25. //HttpRequest request = filterContext.HttpContext.Request;
  26. //string doNotTrack = request.Headers["DNT"];
  27. //if (string.IsNullOrEmpty(doNotTrack) || doNotTrack != "1")
  28. //{
  29. // string title = filterContext.Controller?.ViewBag?.Title;
  30. // string sub = filterContext.RouteData.Values["sub"].ToString();
  31. // if (string.IsNullOrEmpty(sub))
  32. // {
  33. // sub = request.Host.ToUriComponent().GetSubdomain();
  34. // }
  35. // string clientIp = request.ClientIPFromRequest(true);
  36. // string url = UriHelper.GetEncodedUrl(request);
  37. // string urlReferrer = request.Headers["Referer"].ToString();
  38. // string userAgent = request.Headers["User-Agent"].ToString();
  39. // int pixelWidth = request.Browser.ScreenPixelsWidth;
  40. // int pixelHeight = request.Browser.ScreenPixelsHeight;
  41. // bool hasCookies = request.Browser.Cookies;
  42. // string acceptLang = request.Headers["Accept-Language"];
  43. // bool hasJava = request.Browser.JavaApplets;
  44. // // Fire and forget. Don't need to wait for it.
  45. // Tracking.TrackPageView(_config, title, sub, clientIp, url, urlReferrer, userAgent, pixelWidth, pixelHeight, hasCookies, acceptLang, hasJava);
  46. //}
  47. }
  48. }
  49. }