【发布时间】:2016-12-31 17:49:10
【问题描述】:
如何在 FormsAuthentication 中设置和获取 id 和 name
这里只有我设置名字
var user = db.usertable.Where(x => x.UserName == L.UserName && x.password == L.password).FirstOrDefault();
if (user == null)
{
ViewBag.Msg = "invalde user";
return View();
}
else
{
FormsAuthentication.SetAuthCookie(user.UserName, false);
return RedirectToAction("Index", "Home");
}
只有我可以通过此代码获取名称:
System.Web.HttpContext.Current.User.Identity.Name
我可以获取id用户吗?
【问题讨论】:
标签: asp.net-mvc security forms-authentication