Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Visitor group Criterion

Vote:
 

Hi, I have setup a custom criterion that checks for cookie existance as per this post http://tedgustaf.com/blog/2011/10/create-new-visitor-group-criterion-in-episerver/

I have all this setup fine, the trouble im running into is that the criterion is appearing twice:

criteron

I have searched my code in case there was another instance of the class by mistake, which there isnt, also renamed the one I had to double check this.  I then reverted my db to an ealier backup in case it was a previous version, on load I would still have two instances.  All I can think of is something is loading this object twice in the initialisation?

#116383
Jan 29, 2015 12:32
Vote:
 

In case its needed:

Criterion:

[VisitorGroupCriterion(
            Category = "Technical",
            Description = "Determines if the current request contains the specified cookie (lookup by name)",
            DisplayName = "Cookie exists123")]
    public class CookieExistsCriterion : CriterionBase<CookieExistsViewModel>
    {
        public override bool IsMatch(IPrincipal principal, HttpContextBase httpContext)
        {
            if (httpContext.Request == null)
            {
                return false;
            }

            return httpContext.Request.Cookies[this.Model.CookieName] != null;
        }
    }

model:

public class CookieExistsViewModel : CriterionModelBase
    {        
        [Required]
        public string CookieName { get; set; }

        public override ICriterionModel Copy()
        {
            return ShallowCopy();
        }     
    }
#116384
Edited, Jan 29, 2015 12:36
* 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.