I am trying to use UmbracoHelper inside my custom package action. The reason I want to use it is because I need to access the root node to alter its permissions. The examples linked in the documentation uses hardcoded Guids but that won't work for me. Using the code sample beneath throws an CS7069: Reference to type 'HttpContextBase' claims it is defined in 'System.Web' but it could not be found
The code:
public class CustomPackageAction : IPackageAction
{
private readonly IUmbracoContextFactory _context;
public CustomPackageAction(IUmbracoContextFactory context)
{
_context = context;
}
public string Alias() => "CustomPackageAction";
public bool Execute(string packageName, XElement xmlData)
{
using (UmbracoContextReference cref = _context.EnsureUmbracoContext())
{
var cache = cref.UmbracoContext.Content;
}
}
}
I found the solution, so I will leave this here for posterity.
The reason it failed was because I had added a Class Library with target framework .Net Standard 2.0. Upon creating a new Class Library targeting .Net Framework 4.7.2 and referencing a few .dll files from my Umbraco project I was up and running.
Using UmbracoHelper with IPackageAction
The problem:
I am trying to use UmbracoHelper inside my custom package action. The reason I want to use it is because I need to access the root node to alter its permissions. The examples linked in the documentation uses hardcoded Guids but that won't work for me. Using the code sample beneath throws an CS7069: Reference to type 'HttpContextBase' claims it is defined in 'System.Web' but it could not be found
The code:
Does anyone know what might be the solution?
Kind regards
I found the solution, so I will leave this here for posterity.
The reason it failed was because I had added a Class Library with target framework .Net Standard 2.0. Upon creating a new Class Library targeting .Net Framework 4.7.2 and referencing a few .dll files from my Umbraco project I was up and running.
is working on a reply...