Reputation: 297
I am given an error when I try to use Membership.GetUser. Using intellisense the .GetUser() just isn't there.... .AddMember() is. I'm already using System.Web.Security;
Neither of the two below are working
protected void Page_Load(object sender, EventArgs e)
{
string userName = User.Identity.Name;
// Lets get the user's id
Guid userId = (Guid)Membership.GetUser(userName).ProviderUserKey;
MembershipUser user = Membership.GetUser(userName);
}
Error
The type or namespace name 'GetUser' does not exist in the namespace (are you missing an assembly reference?)
Upvotes: 2
Views: 3114
Reputation: 7266
Looks like you have named your page to Membership.aspx and so your code-behind class is named Membership i.e.
public partial class Membership : System.Web.UI.Page
Rename your page and it's code-behind class to avoid any side-wide confusion with built-in asp.net Membership class.
Upvotes: 0
Reputation: 3065
This can be caused by a conflict with another class or folder in the project that is also called Membership. If you can't figure out what the underlying conflict is, you can usually work around it by spelling out the namespace (even though you're already using it).
Like so:
Guid userId = (Guid)System.Web.Security.Membership.GetUser(userName).ProviderUserKey;
Upvotes: 3