这个问题在这里已有答案:
我试过谷歌搜索,但所有的结果似乎是旧版本。
我正在尝试获取登录用户的ID,然后将其与另一个表进行比较。在(sorta)明文我的意思是这样的:
If (the current logged in user's id == Goals.UserId)
{
show all the logged in user's goal
}
如果你正在使用Asp.Net Core
Identity,你可以使用他们的extension
方法来简化对它的访问:
using Microsoft.AspNet.Identity;
[…]
if (User.Identity.GetUserId() == Goals.UserId)
{
// show all the logged in user's goal
}