小编eya*_*win的帖子

电子邮件不能为 null 或为空。MVC 5,身份 2.0.0

我刚刚将我的代码从 Identity 1.0.0 完全迁移到 2.0.0 & 由于某种原因,我遇到了一个奇怪的问题。尝试创建用户时,失败。错误是:电子邮件不能为空或为空。(当然,我将有效的电子邮件插入到该属性中)。请帮忙..

控制器.cs

        [HttpPost]
    [AllowAnonymous]
    [ValidateAntiForgeryToken]
    public async Task<ActionResult> Register(RegisterViewModel model)
    {            
        if (ModelState.IsValid)
        {         
            var user = new ApplicationUser()
            {
                UserName = model.UserName,
                contact_firstname = model.contact_firstname,
                contact_lastname = model.contact_lastname,
                Email = model.Email,
                PhoneNumber = model.PhoneNumber,
                contact_phone2 = model.contact_phone2,
                street = model.street,
                city = model.city,
                country = model.country,
                state = model.state,
                postcode = model.postcode,
                longitude = model.longitude,
                latitude = model.latitude
            };

            var result = await UserManager.CreateAsync(user, model.Password);
            //HERE IS THE ERROR
            if (result.Succeeded)
            {                    
                string …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc-5 asp.net-identity-2

5
推荐指数
1
解决办法
5758
查看次数

标签 统计

asp.net-identity-2 ×1

asp.net-mvc-5 ×1