ICommentEvent runs TWICE in ONE comment

Posted by Community Admin on 04-Aug-2018 08:48

ICommentEvent runs TWICE in ONE comment

All Replies

Posted by Community Admin on 23-May-2016 00:00

I have these code, according to document from sitefinity:

 

_________________________________________________________

protected void Application_Start(object sender, EventArgs e)
       
            Bootstrapper.Initialized += new EventHandler<ExecutedEventArgs>(Bootstrapper_Initialized);
       

_________________________________________________________

public void Bootstrapper_Initialized(object sender, ExecutedEventArgs args)
       
            if (args.CommandName == "Bootstrapped")
           
                EventHub.Subscribe<ICommentEvent>(evt => CommentsEvent.CommentEventHandler(evt));
           
       

_________________________________________________________

and the handler:

_________________________________________________________

 public static void CommentEventHandler(ICommentEvent evt)
       
            // My code here
       

_________________________________________________________

The problem is this handler always runs twice when a comment event happens (post a comment or approve a comment). 

 

Could you please tell me why this happens and any possible way to avoid this? (I don't believe static boolean is a good idea).

 

Thanks

Posted by Community Admin on 26-May-2016 00:00

Hello,

Can you please try to use the below sample code which will execute only once after a comment has been created:

protected void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
        
            if (e.CommandName == "Bootstrapped")
            
                EventHub.Subscribe<ICommentCreatedEvent>(evt => CommentsEventHandler(evt));
            
        
 
        public void CommentsEventHandler(ICommentCreatedEvent eventInfo)
        
                 // your custom code
        

Please also check the below section from our documentation for more details on this:

http://docs.sitefinity.com/for-developers-comments-events#icommentcreatedevent

Regards,
Sabrie Nedzhip
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 03-Jun-2016 00:00

Thanks Sabrie.
I tried this before and the problem is this handler doesn't catch event when i publish a comment (from sitefinity back-end). 
Any solutions?

Posted by Community Admin on 23-Sep-2016 00:00

Any solution for this yet?

This thread is closed