问题描述
要检查的标准方式,如果当前请求进行身份验证与 HttpContext.User.Identity.IsAuthenticated
。我刚才碰到其中用户
属性为空,所以我不能让检查的情况下!
The standard way to check if the current request is authenticated is with HttpContext.User.Identity.IsAuthenticated
. I have just run into a case where the User
property is null so I cannot make the check!
我发现描述IIS请求管道的文章。我在这显然是后的的 PostResolveRequestCache
段的的AuthenticateRequest
!为什么会 HttpContext.User中
仍然为空在这一点?
I found an article describing the IIS request pipeline. I'm at the PostResolveRequestCache
stage which is clearly after AuthenticateRequest
! Why would HttpContext.User
still be null at that point?
推荐答案
的 FormsAuthenticationModule
未运行。我不得不手动将其添加到我的的web.config
和用户
不再是零。我是什么原因导致该模块不跑这里来。
The FormsAuthenticationModule
was not running. I had to manually add it to my web.config
and User
was no longer null. I am investigating what caused the module not to run here.
这篇关于为什么HttpContext.User中零的AuthenticateRequest完成后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!