I'm using SingalR 2 for a chat on my website, but when I call SaveAndPublishWithStatus with raisEvents = false, I still get an Exception "Object reference not set to an instance of an object."
This is my code
var _content = ApplicationContext.Current.Services.ContentService.CreateContent(_contentName, folderId, "_contentType");
ApplicationContext.Current.Services.ContentService.SaveAndPublishWithStatus(_content, 0, false);
Stack trace:
at Umbraco.Web.NotificationServiceExtensions.SendNotification(INotificationService service, IUmbracoEntity entity, IAction action, UmbracoContext umbracoContext, ApplicationContext applicationContext)
at Umbraco.Web.NotificationServiceExtensions.SendNotification(INotificationService service, IUmbracoEntity entity, IAction action, UmbracoContext umbracoContext)
at Umbraco.Core.EnumerableExtensions.ForEach[TItem](IEnumerable`1 items, Action`1 action)
at Umbraco.Core.Events.TypedEventHandler`2.Invoke(TSender sender, TEventArgs e)
at Umbraco.Core.Events.EventExtensions.RaiseEvent[TSender,TArgs](TypedEventHandler`2 eventHandler, TArgs args, TSender sender)
at Umbraco.Core.Services.ContentService.SaveAndPublishDo(IContent content, Int32 userId, Boolean raiseEvents)
at Umbraco.Core.Services.ContentService.SaveAndPublishWithStatus(IContent content, Int32 userId, Boolean raiseEvents)
The content is published, but it's not in the cache.
Oops: The documentis published, but not in the cache (internal error)
What am I missing?
Seems like SaveAndPublishWithStatus(_content, 0, false) still raises events?
Edit: I should mention that I'm using Umbraco 7.2.2
The entry on StackOverflow says to use what I already do: Call the function with UserId = 0 and raiseEvents = false. However, I still get the error in SendNotification.
From StackOverflow:
Notice that applicationContext.Services.ContentService.Save(content,
0, false); contains two extra paramenters: 0 for the user id (zero is
normally the admin user which is always present), and false for
specifying that raiseEvents = false.
Using this approach should ensure that your code doesn't invoke the
NotificationService, which then throws an exception.
SaveAndPublishWithStatus from SignalR 2 Hub class
I'm using SingalR 2 for a chat on my website, but when I call SaveAndPublishWithStatus with raisEvents = false, I still get an Exception "Object reference not set to an instance of an object."
This is my code
Stack trace:
The content is published, but it's not in the cache.
What am I missing? Seems like SaveAndPublishWithStatus(_content, 0, false) still raises events?
Edit: I should mention that I'm using Umbraco 7.2.2
Hi,
There is some great explanation of this exception - http://stackoverflow.com/questions/23558311/umbraco-get-an-error-when-try-to-save-content-using-contentservice
Thanks
Hi Alex
The entry on StackOverflow says to use what I already do: Call the function with
UserId = 0
andraiseEvents = false
. However, I still get the error inSendNotification
.From StackOverflow:
I'm already using theese parameters.
Well. Unable to find out why it sends notification when raiseEvents is set to false, this is my "solution":
Ok. This is weird? SaveAndPublishWithStatus sends notifications, but Save does not?
is working on a reply...