在asp.net中设置Request.IsAuthenticated = true

时间:2009-07-31 14:17:23

标签: asp.net authentication membership

  

可能重复:
  asp.net membership IsApproved false but still allowing login

我有一个用户注册但是IsApproved是假的,但当我检查Request.IsAuthenticated时它仍然返回true。

你知道这会怎么样吗?

1 个答案:

答案 0 :(得分:18)

如果HttpContext.User.Identity不为null且它的IsAuthenticated属性返回true,则

HttpRequest.IsAuthenticated返回true。

当前身份在FormsAuthenticationModule中设置,但它与您的MembershipProvider无关。实际上,它甚至没有引用它。它所做的只是检查身份验证cookie是否仍然设置并且仍然有效(原样,尚未过期)。

我认为问题在于您正在调用FormsAuthentication之类的RedirectFromLoginPage方法之一,即设置身份验证Cookie。如果您需要等到用户获得批准,那么您需要确保没有设置cookie。