Custom Membership with Microsoft.AspNet.Identity - CreateLocalUser fails

后端 未结 3 567
傲寒
傲寒 2021-01-30 14:43

I\'ve been trying to implement a custom version of the new Identity features in ASP.NET 4.5 (Microsoft.AspNet.Identity), using Visual Studio 2013. After many hours of playing a

3条回答
  •  死守一世寂寞
    2021-01-30 15:16

    PulseUser.Id is defined as a string but doesn't appear to be set to a value. Were you meant to be using a GUID for the Id? If so, initialise it in the constructor.

        public PulseUser() : this(String.Empty) { }
        public PulseUser(string userName) 
        {
            UserName = userName;
            Id = Guid.NewGuid().ToString();
        }
    

    You will also want to perform a check that the user name doesn't already exist. Look at overriding DbEntityValidationResult in PulseDbContext. Do a new MVC project in VS2013 to see an example.

提交回复
热议问题