这是为了我的项目,我正在寻求帮助,因为我在MVC ASP.NET中发现我的ViewProfile
页面有困难。
我已经成功地使用了FormsAuthentication,这样我就可以在登录后显示我的名字,但是我已经为ViewProfile
创建了一个链接,在那里我可以显示我可以从数据库中获得的注册详细信息。但我不能做到这一点。有人能帮我解决这个问题吗?
我不是在用EntityFramework,顺便说一下...
发布于 2017-04-15 14:05:03
您可以使用以下代码获取信息
//// // Instantiate the ASP.NET Identity system
var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
var currentUser = manager.FindById(User.Identity.GetUserId());
// Recover the profile information about the logged in user
ViewBag.description = currentUser.UserName;
在你看来
<h3>@ViewBag.description</h3>
你必须使用用户管理器,这对我很有效,但请记住,这只显示信息。
https://stackoverflow.com/questions/43422530
复制相似问题