Hangfire mvc/razor pages referencing ClaimsIdentity

hi, i can send simple emails via hangfire but whenever my method references ClaimsIdentity or UrlHelper page model there is a null reference exception on that part of the code e.g.

 public async Task Simpleemail()
    { var callbackUrl = Url.Page(
         "/Account/ConfirmTask",
         pageHandler: null,
         values: new { area = "Identity", code = code, Id = '8' },
         protocol: Request.Scheme);} OR
   
var claimsIdentity = (ClaimsIdentity)this.User.Identity;
       var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier);

In the document there is some information about passing dependencies or using Ioc containers but Im not sure how to implement them. Any advise or example will be much appreciate.