为什么 HttpContext.User.Identity.Name 不规则地为空?

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

context.User.Identity.Name 很少会为空。我不认为这是可能的,因为我在使用之前检查用户是否经过身份验证,如果没有,则重定向到登录页面。这段代码在 99% 的时间里运行良好,但有时我在尝试 GetMemberNumber 时遇到问题,因为传递的值是空的。有人知道这里会发生什么吗?

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">

代码执行不会在重定向后停止。

    public override async Task ProcessRequestAsync(HttpContext context)
           {
               if (!context.User.Identity.IsAuthenticated)
               {
                   FormsAuthentication.RedirectToLoginPage();
                   return;
               }
    
    
               var memberNumber = MembershipUtils.GetMemberNumber(context.User.Identity.Name);
    
               var remediationServiceProviderResult = await Global.RestrictedAccess
                   .GetRemediationServiceProviderResult(memberNumber);
    
               //...irrelevant code
           }