我在以编程方式保存内容时遇到问题,我单击电子邮件消息上的链接并被带到该站点,在这种情况下,CMS 已更新。但是,如果我再次单击该链接,则会收到以下错误:
无法保存非当前版本
" at Umbraco.Core.Persistence.Repositories.Implement.DocumentRepository.PersistUpdatedItem(IContent entity)\r\n
at Umbraco.Core.Cache.DefaultRepositoryCachePolicy`2.Update(TEntity entity, Action`1 persistUpdated)\r\n
at Umbraco.Core.Persistence.Repositories.Implement.RepositoryBase`2.Save(TEntity entity)\r\n
at Umbraco.Core.Services.Implement.ContentService.<>c__DisplayClass57_0.<CommitDocumentChangesInternal>g__SaveDocument|2(IContent c)\r\n
at Umbraco.Core.Services.Implement.ContentService.CommitDocumentChangesInternal(IScope scope, IContent content, ContentSavingEventArgs saveEventArgs,
IReadOnlyCollection`1 allLangs, Int32 userId, Boolean raiseEvents, Boolean branchOne, Boolean branchRoot)\r\n
at Umbraco.Core.Services.Implement.ContentService.SaveAndPublish(IContent content, String culture, Int32 userId, Boolean raiseEvents)\r\n
at Web.Controller.Controllers.ContactController.CoachConfirmed(String id)
代码如下
var contentService = Services.ContentService;
var content = contentService.GetById(new Guid(coachDocType));
content.SetValue("numberOfTrainees", newNumberOfSpaces);
content.SetValue("numberOfTraineesFollowing", newNumberOfSpacesTaken);
contentService.SaveAndPublish(content);
在 V7 中,我曾经能够执行 ApplicationContext.Current.Services.ContentService.RePublishAll();,但 V8 似乎不再具有该选项
任何帮助,将不胜感激
乔治