使用User.Identity.GetUserId()

时间:2014-05-30 07:36:19

标签: asp.net-mvc

我有这个返回0的代码

var currentUser = User.Identity.GetUserId();
var businesses = db.Businesses.Where(num => num.BusinessEmail == currentUser);

ViewBag.CurrCount = businesses.Count();

此代码返回7

var businesses = db.Businesses.Where(num => num.BusinessEmail == "myname@mysite.com");

ViewBag.CurrCount = businesses.Count();

myname@mysite.com 是User.Identity.GetUserId();

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

var currentUser = User.Identity.Name;

昨晚我有点累了!