I changed to contentService.SaveAndPublishWithStatus(profile, raiseEvents: false); to dose not fire any event but it's still error.
Ps: I got the exception but the content is saved but the "Link to Document" is " Oops: this document is published but is not in the cache (internal error)"
Here is my code, my project contains this class only
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Linq;
using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.web;
using Umbraco.Core;
namespace MyUmbraco
{
public class CreateContent : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
var root = applicationContext.Services.ContentService.GetRootContent();
var content = applicationContext.Services.ContentService.CreateContent("get start", -1, "umbTextPage");
applicationContext.Services.ContentService.SaveAndPublishWithStatus(content);
base.ApplicationStarted(umbracoApplication, applicationContext);
}
}
}
Get an error when try to save content using ContentService
I'm using ApplicationEventHanlder to create a content once application started. Here is my code
However, it gave me an error (applicationContext.Services.ContentService.Save(content);), the stack trace here:
Is anyone similar with this error and provide me a solution?
Thanks!
Hi Duong
What version of Umbraco are you using? And are you using webforms or MVC as the template engine?
/Jan
Hi Jan,
I'm using Umbraco version 7.1.1 and MVC template. Please help me on this error.
Thanks
I changed to
contentService.SaveAndPublishWithStatus(profile, raiseEvents: false);
to dose not fire any event but it's still error.Ps: I got the exception but the content is saved but the "Link to Document" is " Oops: this document is published but is not in the cache (internal error)"
Hi Duong
Could you share your code please?
/Jan
Here is my code, my project contains this class only
Hi Duong
Sorry, missed the sample you posted in the first post.
However I'm thinking...do you have the document type alias of "umbTextPage" in your solution?
/Jan
Jan, yes I have the document type with alias "umbTextPage" in my site. "umbTextPage" is document type of Txt starter kit
is working on a reply...