maartenba / GoogleAnalyticsTracker

GoogleAnalyticsTracker - A C# library for tracking Google Analytics
Microsoft Public License
290 stars 111 forks source link

GoogleAnalyticsTracker.WebApi.AsyncActionFilterAttribute Exception #110

Closed mikemike396 closed 7 years ago

mikemike396 commented 7 years ago

Getting the current error only under certain calls. WebAPI 2.0. Any thoughts?

{"Message":"An error has occurred.","ExceptionMessage":"Object reference not set to an instance of an object.","ExceptionType":"System.NullReferenceException","StackTrace":" at GoogleAnalyticsTracker.WebApi.AsyncActionFilterAttribute.d__1.MoveNext()"}

using GoogleAnalyticsTracker.WebApi;
using System;

namespace API.Analytics
{
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
    public class GoogleAnalytics : ActionTrackingAttribute
    {
        public GoogleAnalytics() : base("xx-xxxxxxx-x") { }
    }
}
maartenba commented 7 years ago

Try GoogleAnalyticsTracker.WebAPI2 package

mikemike396 commented 7 years ago

I found out that this line is what is causing the crash. Any idea? If I remove this line it works fine, and if I comment the GoogleAnalytics decoration on this method it works fine.

HttpContext.Current.Request.ServerVariables["REMOTE_HOST"].ToString()

maartenba commented 7 years ago

This line is nowhere in the codebase? Are you using the WebAPI2 package? Which version?