Link to home
Start Free TrialLog in
Avatar of WorknHardr
WorknHardr

asked on

Custom ExtendedMemebershipProvider MembershipUser GetUser Object Instance Error?

I keep getting the error: "Object reference not set to an instance of an object." on the italic code below. It code seems straight forward, Intellisense is happy and it compiles in VS2012. The only problem is that it won't run in a browser without error. I guess the MemberShipUser doesn't want to play nice. Help!

Note: This code runs after clicking the Login 'Submit' button.

Q. How Do I get this method to return a MembershipUser?

public override MembershipUser GetUser(string username, bool userIsOnline)
        {
            var user = (from u in entities.Users.ToList() where u.UserName == username select u).FirstOrDefault();

            var member = new MembershipUser(this.Name, user.UserName, user.UserID, user.Email, null, null, true, (bool)user.IsLockedOut, System.DateTime.Now, System.DateTime.Now, System.DateTime.Now, System.DateTime.Now, System.DateTime.Now);

            return member;
        }
ASKER CERTIFIED SOLUTION
Avatar of deanvanrooyen
deanvanrooyen

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of WorknHardr
WorknHardr

ASKER

Thanks, I'm going in the right direction now...
cool, nice one...