Inject UmbracoHelper in Service
# help-with-umbraco
s
For some reason I'm having real trouble injecting UmbracoHelper into a specific controller + service setup. But I also have a pretty much identical setup with another controller that works. Check the images for the news controller, inewsservice and newsservice and its composer. This works fine with the UmbracoHelper. Also check the images for the robots controller, interface, service and composer. This breaks if when I try to inject the UmbracoHelper (the controller stops triggering at all). I'm not quite sure what the heck is going on here as it seems everything is identical but for some reason, the robots controller is not working. https://cdn.discordapp.com/attachments/1298190786164424715/1298190786403238008/image.png?ex=6718a9e2&is=67175862&hm=eedc91576cc09d44dc1c822afc136f56f99f471bd5c8b0db69cdbb12d1bfb389& https://cdn.discordapp.com/attachments/1298190786164424715/1298190786642579548/image.png?ex=6718a9e2&is=67175862&hm=14e45d9164020738bfa085b1953b07826ba2e753cbf45d565dfb723272a75474& https://cdn.discordapp.com/attachments/1298190786164424715/1298190786927530015/image.png?ex=6718a9e2&is=67175862&hm=a3f50dffd33083ca73657055db7d4a7b2be7e0ce9b2ae73abdf2cf6ee361d1e2& https://cdn.discordapp.com/attachments/1298190786164424715/1298190787263201332/image.png?ex=6718a9e2&is=67175862&hm=a3c9f32e7e97655630b4e2bee9c1861333ebb1718f30e6a190572b259d439b95& https://cdn.discordapp.com/attachments/1298190786164424715/1298190787561000960/image.png?ex=6718a9e2&is=67175862&hm=f063d274beb2d37fc8098bb264078bce4eab56f87e4ba20269a0f96cfc129e02& https://cdn.discordapp.com/attachments/1298190786164424715/1298190787829305426/image.png?ex=6718a9e3&is=67175863&hm=7c3dce9686b95dc801b36bd84c550289698aaf37ac2b5a903e425c2d5cd76633& https://cdn.discordapp.com/attachments/1298190786164424715/1298190788080959539/image.png?ex=6718a9e3&is=67175863&hm=dc01f4e5b18fef9380a028daba5307d0195cc8b949a3a9bd0fc6bf692511eb46& https://cdn.discordapp.com/attachments/1298190786164424715/1298190788307718186/image.png?ex=6718a9e3&is=67175863&hm=298202b749df70cd42d30f08d16ebfb7fd946058054864600fb157499e50ba33&
j
IIRC the UmbracoHelper can only function properly if you have a routed request. So fx background services, etc would not be able to get the correct Umbraco Context. For that you can instead use the IUmbracoContextFactory to get the context and then get nodes, etc
d
Jemayn is completely correct here!
3 Views