I am actually moving an old project which is classic webservice in C# (ASMX) to WebAPI asp.net core 3.1
Since without any previous experience in Web API I'm facing some challenges in conversion.
Here is a code snippet I was using ASMX to get current user
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(ctx,
HttpContext.Current.User.Identity.Name);
UserName = userPrincipal.DisplayName;
What I did is created a class file kip.cs and in an empty method I pasted this code.
But HttpContext highlights of an error saying Httpcontext not exists in this context. So what should I use to get it work