'Why is HttpContext.User.Identity.Name irregularly empty?

context.User.Identity.Name will very rarely be empty. I did not think this was possible since I'm checking if the user is authenticated before using it, and redirecting to the login page if they are not. 99% of the time this code runs fine, but I'm sometimes having issues when trying to GetMemberNumber, as the value that is being passed is a empty. Does anyone have any ideas what could be going on here?

FromRA.ashx.cs

using System;
using System.Threading.Tasks;
using System.Web;
using System.Web.Configuration;
using System.Web.Security;
using Helpers;

namespace Transfer
{
   public class FromRA : HttpTaskAsyncHandler
   {
       public override async Task ProcessRequestAsync(HttpContext context)
       {
           if (!context.User.Identity.IsAuthenticated)
               FormsAuthentication.RedirectToLoginPage();

           var memberNumber = MembershipUtils.GetMemberNumber(context.User.Identity.Name);

           var remediationServiceProviderResult = await Global.RestrictedAccess
               .GetRemediationServiceProviderResult(memberNumber);

           //...irrelevant code
       }
   }
}

Web.config

<authentication mode="Forms">



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source