I tried to get the current user Id through the User.Identity but in vain, i found This post
that guided me to do the following : Guid userGuid = (Guid)Membership.GetUser().ProviderUserKey;
i went through the same mistake as in This Post! however the solution provided didn't work in my case. I have an accounts model as
public class Account
{
public int ID { get; set; }
......
}
i want to link the billing information created to the currently logged in user so i tried doing the following as suggested
if (User.Identity.IsAuthenticated)
{
Guid userGuid = (Guid)Membership.GetUser().ProviderUserKey;
billinginfo.User = db.AccountSet
.Where(x => x.ID == userGuid).FirstOrDefault();
}
and i have the obvious error :
Operator '==' cannot be applied to operands of type 'int' and 'System.Guid' i couldn't get an answer from This Post i tried to convert the Guid to int but that generated a wrong id since the conversion is utmost to 64 bits
So i want to get the currently logged in user and be able to access all his attributes
Any help is appreciated!