Request.IsAuthenticated is always false

前端 未结 10 2160
迷失自我
迷失自我 2020-12-15 04:34

Can you tell me why FormsAuthentication.SetAuthCookie(user.Name, false); is not causing Request.IsAuthenticated to be true?

Here is my code

10条回答
  •  粉色の甜心
    2020-12-15 05:17

    You are checking if the user is authenticated. So use:

    if (User.Identity.IsAuthenticated) 
    

    This will fix the issue and as mentioned set the authentication element in your web.config to Forms and not Windows.

提交回复
热议问题