Search code examples
c#asp.net-mvc-3asp.net-membershipmembership-provider

Membership.Providers GetUser returns null when using username


The top function is returning a membership user while the second one does not. I've passed in the username for a user for whom the top function gets a result but the second just returns null. Any suggestions to get user based on username?

public static MembershipUser getCCUser(Guid UserID)
{
   return ((MembershipProvider)Membership.Providers["CC_MembershipProvider"]).GetUser(UserID, false);
}

public static MembershipUser getCCUser(string userName)
{
   return ((MembershipProvider)Membership.Providers["CC_MembershipProvider"]).GetUser(userName, false);
}

Solution

  • The applicationNames in the web.config should match the application name in aspnet_Applications table