更新时间:2023-11-30 17:54:16
您不需要使用SigninManager或类似的东西。将用户注入到管道中(在基本控制器的User属性上),身份验证中间件(cookie或令牌)会自动填充其信息。因此,在您的控制器上:
You don't need to use the SigninManager or something similar. The user is injected on the pipeline (on the User property of the base controller) and it's info is filled automatically by the authentication middleware (cookie or token). So, on your controller:
bool isAuthenticated = User.Identity.IsAuthenticated;