HttpContext.Current.User null reference exception in c#

This is my application structure

Project structure

i am running my application under IIS Express thats why i am manually setting the forms authentication in the login web api controller when the user signs in from the UI

        public HttpResponseMessage GetUser([FromBody]UsersModel model) {
            try {
                var result = _userService.GetUser(model.UserName, model.Password);
                if (result.Count > 0) {
                FormsAuthentication.SetAuthCookie(result[0].UserName, true);
                string test = HttpContext.Current.User.Identity.Name;
                     return Request.CreateResponse(HttpStatusCode.Created,result);
                } else {
                    return Request.CreateResponse(HttpStatusCode.NoContent, result);
            } catch (Exception ex) {
                throw ex;


 public static void  SetAuthentication() {
            HttpCookie authCookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
            if (authCookie != null) {
                FormsAuthenticationTicket authTicket = null;
                authTicket = FormsAuthentication.Decrypt(authCookie.Value);

                if (authTicket != null && !authTicket.Expired) {
                    FormsAuthenticationTicket newAuthTicket = authTicket;

                    if (FormsAuthentication.SlidingExpiration) {
                        newAuthTicket = FormsAuthentication.RenewTicketIfOld(authTicket);
                    string userData = newAuthTicket.UserData;
                    string[] roles = userData.Split(',');
                    Thread.CurrentPrincipal = HttpContext.Current.User = new GenericPrincipal(new FormsIdentity(newAuthTicket), roles);

I am able to get the user name from HttpContext.Current.User.Identity.Name in the login webapi controller but when i try to get the user name from a different web api controller using HttpContext.Current.User.Identity.Name i am getting null reference error

how can i make the user data persistent in forms auth and access through out the entire application using HttpContext.Current.User.Identity.Name???