User
should have Items
. Should I store the User's Id
in Item
? Can I extend the User
class with an List<Item>
navigation property?I'm using "Individual User Accounts" from the MVC template.
Tried these:
'Membership.GetUser()' is null.
If you're coding in an ASP.NET MVC Controller, use
using Microsoft.AspNet.Identity;
...
User.Identity.GetUserId();
Worth mentioning that User.Identity.IsAuthenticated
and User.Identity.Name
will work without adding the above mentioned using
statement. But GetUserId()
won't be present without it.
If you're in a class other than a Controller, use
HttpContext.Current.User.Identity.GetUserId();
In the default template of MVC 5, user ID is a GUID stored as a string.
No best practice yet, but found some valuable info on extending the user profile:
Identity
: https://devblogs.microsoft.com/aspnet/introducing-asp-net-identity-a-membership-system-for-asp-net-applications/