0

I'd like to use the UserId value for the logged in user to identify the user after login.

What I envision happening is that the user will login, and FormsAuthentication will get a Username whereas some other object will store the User Id (in asp.net I would use a Session variable).

After a quick look around I don't believe a Session would be practical in this case given how much work it'd be to set up (yes, I'm a lazy dev...)

The thing is, in my _LoginPartial view, I want to set the welcome message:

Welcome, back @Html.ActionLink(User.Identity.Name, "Manage", "Account", <user id here>)!

But I don't know how to get that user id value back from the login (or somewhere where I can access it to retrieve user information later).

Can anyone make any recommendations?

Ortund
  • 8,095
  • 18
  • 71
  • 139

1 Answers1

0

I will recommand you to use the WebMatrix.WebData namespace. It contains classes that simplify membership and security in ASP.NET Web Pages. This namespace includes classes that help you create and delete user accounts, define roles, and manage account passwords.

So In your case you will just use WebSecurity.CurrentUserId after someone logged to get the UserIdin instead of recreating the wheel. It will require time to read and to use it properly but at the end will save you time.

This question will give you more insight.

Community
  • 1
  • 1