Using MediaService on Application Start without delaying project initialising
Hi,
I'm trying to do a bulk operation on a huge amount of media items. I'm trying to do it asynchronously in the application start up so it doesn't take 5 minutes for the site to start on a app pool refresh. I'm using the media service but the media object is coming back null. Without it being called asynchronously it works fine.
I'm getting a an exception of type 'System.ArgumentNullException' occurred in System.Web.dll but was not handled in user code. Although when I debug I can see object properties being populated.
Using
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext){
System.Threading.Tasks.Task.Run(() => Build(applicationContext));
}
private void Build(ApplicationContext applicationContext)
{
var cs = applicationContext.Services.ContentService;
var node = cs.GetById(225353);
node.Name = test;
cs.SaveAndPublishWithStatus(node);
}
Error occurring on the SaveAndPublishWithStatus method
Using MediaService on Application Start without delaying project initialising
Hi,
I'm trying to do a bulk operation on a huge amount of media items. I'm trying to do it asynchronously in the application start up so it doesn't take 5 minutes for the site to start on a app pool refresh. I'm using the media service but the media object is coming back null. Without it being called asynchronously it works fine.
I'm getting a an exception of type 'System.ArgumentNullException' occurred in System.Web.dll but was not handled in user code. Although when I debug I can see object properties being populated.
Using
Error occurring on the SaveAndPublishWithStatus method
is working on a reply...