Developer forum

Forum » Development » commentArgs always return

commentArgs always return

Kim Søjborg Pedersen
Reply

Hi 
commentArgs is always null when I run this code (Sample from api doc), I have no problem with other notifications. Its the same with all the CommentNotifications i have tried.

What can be wrong?


using Dynamicweb.Extensibility.Notifications;
using Dynamicweb.Notifications;

namespace Dynamicweb.Examples.Notifications
{
    [Subscribe(CommentNotification.OnAfterSave)]
    public class OnAfterSaveObserver : NotificationSubscriber
    {
        public override void OnNotify(string notification, NotificationArgs args)
        {
            var commentArgs = args as CommentNotification.CommentArgs;

            //Add code here
        }
    }
}

Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Have you stepped through this with the debugger and looked at the type of the args instance? Maybe it's of a different type?

 
Kim Søjborg Pedersen
Reply

Yes the type of args is {Dynamicweb.Notifications.Commenting.CommentArgs} but it states that Commenting is Obsolete

 
Kim Søjborg Pedersen
Reply

I can make it work with the obsolete class :)

var commentArgs = args as Dynamicweb.Notifications.Commenting.CommentArgs;

 

You must be logged in to post in the forum