Personalization

Vote:
 

Howdy,

I am attemtping to create a custom visitor group that looks for a user agent that the web editor specifies.

My model

    public class BrowserModel : CriterionModelBase
    {

        [Required]
        public string UserAgentName { get; set; }

        public override ICriterionModel Copy()
        {
            return ShallowCopy();
        }

    }

My Criterion

[VisitorGroupCriterion(
        Category = "Custom Criteria",
        DisplayName = "User Agent",
        Description = "Criterion that matches the user agent"
    )]
    public class BrowserCriterion : CriterionBase
    {

        public override bool IsMatch(IPrincipal principal, HttpContextBase httpContext)
        {
            return httpContext.Request.UserAgent.Equals(Model.UserAgentName);
        }

    }

Pretty simple criterion, the web editor creates a new visitor group, inserts a user agaent and hits save, however upon hitting save the following error is returned:

RequestError: Unable to load /EPiServer/Cms/VisitorGroups/SaveVisitorGroup status: 500

I am unable to proced any further, does anyone have any thoughts as to what is wrong?

#117309
Feb 17, 2015 15:45
Vote:
 

Hi Peter 

There is an open source project that does something very similar. I suggest you check it out for inspiration: http://criteriapack.codeplex.com/wikipage?title=BrowserOSCriterion&referringTitle=Home

David

#117315
Feb 17, 2015 18:10
Vote:
 

Thanks David, I have since got this Visitor group working.

Solution: I deleted both class then recreated them. Built and tested the solution, it worked.

#117332
Edited, Feb 18, 2015 10:23
Vote:
 

The visitor group criteria pack that David mentioned is also available as a supported add-on for EPiServer CMS 7.5 and above, available in our Nuget feed: http://nuget.episerver.com/en/OtherPages/Package/?packageId=EPiServer.VisitorGroupsCriteriaPack

#117338
Feb 18, 2015 11:13
Vote:
 

Well, you did get the visitor group working but without solving the problem. Deleting files and/or add a nuget package is not a solution to the error. ;)

RequestError: Unable to load /EPiServer/Cms/VisitorGroups/
SaveVisitorGroup status 500


My guess is that you did changes in your visitor group model. Since the vistor group model (somehow) is saved in the DDS, you need to set an attribute on your model class to force a remapping of the model.

[EPiServerDataStore(AutomaticallyRemapStore = true)]

This will do the trick with your original files.

Regards,

Andreas

#145858
Mar 14, 2016 14:19
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.