Bug in VisitHandler?


I'm am using visithandler to count visit for two visitable entities, namely Entry and Blog. The following code is used for this...

VisitHandler.AddVisit(new EPiServer.Common.Visits.Visit(_blog, new UserAuthor(CurrentUser)));
VisitHandler.AddVisit(new EPiServer.Common.Visits.Visit(_entry, new UserAuthor(CurrentUser)));

When trying to receive Entry visits i also receive Blog visits and vice versa, this has to be a bug? I can't find anything in the bug list. The following code is used.

VisitableEntityCollection visitedItems = VisitHandler.GetVisitedItems(typeof(Entry), 1,
                1000, TimeSpan.MinValue, out totalItems, new VisitableEntitySortOrder(VisitableEntitySortField.NumVisits, SortingDirection.Descending))

Apr 26, 2010 10:50


This is a known issue which does not yet have a publicly released fix. You can get a hotfix through EPiServer Support.

We will look into why this is not in the bug list.



Apr 27, 2010 10:18

You can try this workaround - not very nice but seems to work well:

using System;
using System.Linq;
using EPiServer.Common.Visits;

namespace Utils
    public class VisitHandlerFix
        private const int MaxItemCount = 10000;

        public static VisitableEntityCollection GetVisitedItems<T>(int page, int pageSize, TimeSpan explicitCacheExpiration, out int totalItems, params VisitableEntitySortOrder[] sortOrder)
            // bugfix:
            VisitableEntityCollection everything = VisitHandler.GetVisitedItems(typeof(T), 1, MaxItemCount, explicitCacheExpiration, out totalItems, sortOrder);
            VisitableEntityCollection filtered = new VisitableEntityCollection(everything.OfType<T>().ToList());
            totalItems = filtered.Count;

            return new VisitableEntityCollection(filtered.Skip(pageSize * (page - 1)).Take(pageSize).ToList());

Aug 27, 2010 17:54
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.