我有自己的身份验证系统 ( https://bitbucket.org/anton_gogolev/octalforty-structural ),它不使用任何标准的 ASP.NET 东西 ( <authentication mode="None" />)。
它使用 plain IHttpModules 来完成它的工作:BeginRequest检查传入的 cookie 和设置HttpContext.Current.User,并Thread.CurrentPrincipal在成功验证后
Thread.CurrentPrincipal = HttpContext.Current.User =
new GenericPrincipal(tokenIdentity,new string[] { });
而EndRequest为经过身份验证的用户发出所有必需的 cookie。
这几个月来一直运行良好,但在某些系统上(我真的无法判断它们与实际运行的系统有何不同)ASP.NET 似乎正在失去 的值HttpContext.Current.User,用任何默认值替换它(GenericPrincipal聚合GenericIdentity设置IsAuthenticated为false等)。
所以问题是:如何以及为什么会HttpContext.Current.User迷路?