Umbraco 9 - contentHelper.GetById shows old data for background task
Hi All,
I have a really strange error.
I have a scheduled tasks that runs every day. I use hangfire to handle this.
As part of the scheduled task I am doing a simple contentHelper.GetById(Id) lookup.
For some reason the data that comes back is an old version. I test cleaning the database and xml cache from within Umbraco and this has Zero effect. The only way I can get it to see the new published data is by stopping visual studio, rebuilding and run again. This then seems to work.
I ran some more test....
I start the data from fresh so everything is looking good in the debugger.
I then manually trigger the sceduled task (all ok)
I then run the exact same method getting the content from RajorScript (all ok)
I then edit the content node I am looking up within Umbraco backend (save and publish). I click on and off the node to check the changes have updated ok (they have)
I then manually trigger my scheduled task and it is seeing the old data from before.
I then run the exact same method again from Razor and the data is ok.
I run my sceduled task again and the data is still the old data. So the exact same method is bringing back different data if called from Razor or my Background Task.
If I stop Visual Studion, rebuild, run and test again then the data called from both in the background task and the RazorScript are the same again.
Very Odd.
Does anyone know why this might be happening and more importantly does anyone know how I can force my background tasks to get the most recent data?
Umbraco 9 - contentHelper.GetById shows old data for background task
Hi All,
I have a really strange error. I have a scheduled tasks that runs every day. I use hangfire to handle this.
As part of the scheduled task I am doing a simple contentHelper.GetById(Id) lookup.
For some reason the data that comes back is an old version. I test cleaning the database and xml cache from within Umbraco and this has Zero effect. The only way I can get it to see the new published data is by stopping visual studio, rebuilding and run again. This then seems to work.
I ran some more test....
I start the data from fresh so everything is looking good in the debugger.
I then manually trigger the sceduled task (all ok)
I then run the exact same method getting the content from RajorScript (all ok)
I then edit the content node I am looking up within Umbraco backend (save and publish). I click on and off the node to check the changes have updated ok (they have)
I then manually trigger my scheduled task and it is seeing the old data from before.
I then run the exact same method again from Razor and the data is ok.
I run my sceduled task again and the data is still the old data. So the exact same method is bringing back different data if called from Razor or my Background Task.
If I stop Visual Studion, rebuild, run and test again then the data called from both in the background task and the RazorScript are the same again.
Very Odd.
Does anyone know why this might be happening and more importantly does anyone know how I can force my background tasks to get the most recent data?
Here is the method I am using to get the data.
Hi All,
I managed to find a work around. I would still like to undertsand what is happening here through.
My work around was to wrap all my logic inside an UmbracoApiController. Then my background task simply does a HttpClient Get Request.
This will do nicely for now though.
Eg.
is working on a reply...